PHPackages                             balfour/attribution-tracker - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. balfour/attribution-tracker

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

balfour/attribution-tracker
===========================

A library for assigning an attribution channel to an entity based on tracking properties of that entity.

015PHP

Since May 22Pushed 6y ago6 watchersCompare

[ Source](https://github.com/balfour-group/attribution-tracker)[ Packagist](https://packagist.org/packages/balfour/attribution-tracker)[ RSS](/packages/balfour-attribution-tracker/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

attribution-tracker
===================

[](#attribution-tracker)

A library for assigning an attribution channel to an entity based on tracking properties of that entity.

*This library is in early release and is pending unit tests.*

Use Case
--------

[](#use-case)

A typical use case is that you have a trackable entity (a `user` or `lead`) which registers or is created via an API, with one or many tracking properties (`http_referer`, `utm_source`, `utm_medium``gclid`, etc).

Given the entity and its tracking properties, you'd like to classify it into an attribution channel, and store that attribution channel (`Organic Search -> Google`) against the entity for reporting purposes.

Installation
------------

[](#installation)

```
composer require balfour/attribution-tracker
```

Usage
-----

[](#usage)

**Step 1:**

You create an AttributionTracker and define your tracking rules.

This repo includes a `GenericChannel` class for ease of use; although you can create a custom class implementing the `ChannelInterface`. In a real world app, your channels &amp; rules might be models loaded from a database.

```
use Balfour\AttributionTracker\AttributionTracker;
use Balfour\AttributionTracker\GenericChannel;
use Balfour\AttributionTracker\Rules\GoogleAdsRule;
use Balfour\AttributionTracker\Rules\GoogleTrackingRule;
use Balfour\AttributionTracker\Rules\HttpRefererRule;

$tracker = new AttributionTracker();

$channel1 = new GenericChannel('Direct', 'Direct');
$tracker->setDefaultChannel($channel1);
// if the tracker can't find a matching rule, the default channel is returned

$channel2 = new GenericChannel('Paid Media', 'Google');
$rule1 = new GoogleAdsRule($channel2);
$tracker->addRule($rule1);

// this will match on utm_source = google AND utm_medium = ppc
$rule2 = new GoogleTrackingRule($channel2, 'google', 'ppc');
$tracker->addRule($rule2);

$channel3 = new GenericChannel('Referral', 'Facebook');
$rule3 = new HttpRefererRule($channel3, 'lm.facebook.com');
$rule4 = new HttpRefererRule($channel3, 'm.facebook.com');
$rule5 = new HttpRefererRule($channel3, 'l.facebook.com');
$rule6 = new HttpRefererRule($channel3, 'www.facebook.com');
$rule7 = new HttpRefererRule($channel3, 'facebook.com');
$tracker->addRules([$rule3, $rule4, $rule5, $rule6, $rule7]);
```

**Step 2:**

You have an object, implementing the `TrackableEntityInterface`, which you'd like to classify.

A `GenericTrackableEntity` is included in this repo; however in a real app, this may be a `user`or `lead` model.

```
use Balfour\AttributionTracker\GenericTrackableEntity;
use Balfour\AttributionTracker\TrackingMeta;

$props = new \stdClass();
$props->http_referer = 'https://google.co.za';
$props->utm_source = 'google';
$props->utm_medium = 'ppc';
$meta = new TrackingMeta($props);

$entity = new GenericTrackableEntity($meta);
```

**Step 3:**

With your `AttributionTracker` and `TrackableEntityInterface`, the entity can be classified.

```
$channel = $tracker->getChannel($entity);

var_dump($channel);
var_dump($channel->getCategory()); // Paid Media
var_dump($channel->getLabel()); // Google
var_dump($channel->getFullName()); // Paid Media -> Google
```

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/054093c4138d9bea138f6226b632f8f7ad0adb516562480f7f77868d481e75f0?d=identicon)[balfourgroup](/maintainers/balfourgroup)

---

Top Contributors

[![matthewgoslett](https://avatars.githubusercontent.com/u/1571743?v=4)](https://github.com/matthewgoslett "matthewgoslett (2 commits)")

### Embed Badge

![Health badge](/badges/balfour-attribution-tracker/health.svg)

```
[![Health](https://phpackages.com/badges/balfour-attribution-tracker/health.svg)](https://phpackages.com/packages/balfour-attribution-tracker)
```

###  Alternatives

[ozdemir/datatables

Simplify your Datatables server-side processing effortlessly using our lightning-fast PHP library, streamlining your workflow seamlessly.

273158.4k](/packages/ozdemir-datatables)[that0n3guy/transliteration

Transliteration provides one-way string transliteration (romanization) and cleans text by replacing unwanted characters.

1296.5k4](/packages/that0n3guy-transliteration)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
