EasyAttrib is a JavaScript attribution tracking system that determines the source and medium of website traffic. It processes various attribution signals in a specific order to provide accurate traffic source attribution.
The system evaluates attribution signals in the following order:
Campaign parameters are processed first and are independent of other attribution logic:
Supported Campaign Parameters:
utm_campaign
(Google Analytics)mtm_campaign
(Matomo)matomo_campaign
(Matomo alternative)pk_campaign
(Piwik)piwik_campaign
(Piwik alternative)cid
(Adobe Analytics)
Priority: First parameter found wins (left-to-right order)
Plugins are evaluated in the order they are provided to the SessionTracker constructor. The default order is:
- UTM Attribution Plugin
- Google Ads Attribution Plugin
- Facebook Attribution Plugin
- Referrer Attribution Plugin
- UTM parameters have the highest priority over click ID plugins
- When both UTM parameters and click IDs are present, UTM source/medium takes precedence
- Click IDs are still preserved for tracking purposes even when UTM overrides
- Click ID plugins (Google Ads, Facebook) can only override existing attribution if:
- No UTM source attribution is present
- The existing source is not from the same click ID plugin
- Attribution preservation is disabled
- By default, existing session attribution is preserved
- New attribution only overrides existing attribution when:
- No existing attribution exists
- Attribution preservation is disabled (
shouldPreserveAttribution: false
) - UTM parameters are being set for the first time
- Click ID plugins meet the override criteria
Supported Parameters:
- Source parameters:
utm_source
,mtm_source
,matomo_source
,pk_source
,piwik_source
- Medium parameters:
utm_medium
,mtm_medium
,matomo_medium
,pk_medium
,piwik_medium
Behavior:
- Returns attribution only if at least one parameter is found
- First parameter found in each category wins
- Can override click ID attribution when both are present
Supported Parameters:
gclid
(Google Ads click ID)
Default Attribution:
- Source:
google_ads
- Medium:
cpc
- Click ID: Value of
gclid
parameter
Behavior:
- Only activates when
gclid
parameter is present - Cannot override UTM source attribution
- Can override other attribution sources when no UTM is present
Supported Parameters:
fbclid
(Facebook click ID)
Default Attribution:
- Source:
meta
- Medium:
social
- Click ID: Value of
fbclid
parameter
Behavior:
- Only activates when
fbclid
parameter is present - Cannot override UTM source attribution
- Can override other attribution sources when no UTM is present
Behavior:
- Only activates when a valid referrer is present
- Ignores same-domain referrers (internal traffic)
- Maps known domains to specific source/medium combinations
- Unknown domains are classified as referral traffic
Domain | Source | Medium |
---|---|---|
google. |
google |
organic_search |
bing. |
bing |
organic_search |
duckduckgo.com |
duckduckgo |
organic_search |
ycombinator.com |
ycombinator |
organic_search |
yahoo.com |
yahoo |
organic_search |
ecosia.org |
ecosia |
organic_search |
startpage.com |
startpage |
organic_search |
yandex.com |
yandex |
organic_search |
brave.com |
brave |
organic_search |
baidu.com |
baidu |
organic_search |
sogou.com |
sogou |
organic_search |
eniro.se |
eniro |
organic_search |
presearch.org |
presearch |
organic_search |
Domain | Source | Medium |
---|---|---|
facebook.com |
facebook |
social |
twitter.com |
twitter |
social |
linkedin.com |
linkedin |
social |
instagram.com |
instagram |
social |
pinterest.com |
pinterest |
social |
reddit.com |
reddit |
social |
quora.com |
quora |
social |
tiktok.com |
tiktok |
social |
youtube.com |
youtube |
social |
medium.com |
medium |
social |
github.com |
github |
social |
stackoverflow.com |
stackoverflow |
social |
dev.to |
dev.to |
social |
x.com |
x |
social |
Domain | Source | Medium |
---|---|---|
chatgpt.com |
chatgpt |
ai-service |
openai.com |
openai |
ai-service |
claude.ai |
anthropic |
ai-service |
anthropic.com |
anthropic |
ai-service |
perplexity.ai |
perplexity |
ai-service |
- Source: Domain name (e.g.,
example.com
) - Medium:
referral
When no attribution is found by any plugin:
- Source:
direct
- Medium:
direct
- Channel:
direct/direct
The system automatically assigns a channel based on source and medium:
- Format:
{source}/{medium}
- Examples:
google/organic_search
facebook/social
google_ads/cpc
meta/social
direct/direct
- New sessions are created when no existing session is found
- Sessions include landing page URL, referrer, timestamp, and attribution data
- Multi-tab support with automatic session cleanup when all tabs close
- Sessions are stored in localStorage by default
- Attribution data is preserved across page views within the same session
- Sessions persist until all browser tabs are closed
- Set cookie
x-attrib-test=enabled
to enable debug logging - Debug mode shows detailed attribution processing steps
- Can be overridden by constructor
debug
option
When debug mode is enabled, the system logs:
- Plugin evaluation steps
- Attribution decisions
- Session state changes
- Override logic decisions
plugins
: Array of attribution plugins (default: UTM, Google Ads, Facebook, Referrer)debug
: Boolean to enable debug modeshouldPreserveAttribution
: Boolean to control attribution preservation (default: true)storage
: Storage interface (default: localStorage)sessionKey
: Session storage key (default: 'easyattrib_sessions')tabsKey
: Active tabs storage key (default: 'easyattrib_active_tabs')
URL: example.com?utm_source=newsletter&gclid=abc123
Result: source=newsletter, medium=undefined, clickId=abc123, channel=newsletter/undefined
URL: example.com?gclid=abc123
Result: source=google_ads, medium=cpc, clickId=abc123, channel=google_ads/cpc
Referrer: https://www.google.com/search?q=example
Result: source=google, medium=organic_search, clickId=null, channel=google/organic_search
URL: example.com (no parameters, no referrer)
Result: source=direct, medium=direct, clickId=null, channel=direct/direct