Web Traffic Campaign Tracking with Snowplow: A Technical Tutorial for Engineers
Understanding which marketing campaigns drive high-quality traffic to your website is a foundational use case in digital analytics. But accurately attributing traffic sources—particularly in web environments—requires robust infrastructure and thoughtful data modeling. In this tutorial, we walk through how to implement campaign tracking for web-driven traffic using Snowplow, focusing on two powerful enrichments: Referer Parser Enrichment and Campaign Attribution Enrichment.
This guide assumes you're working with a Snowplow pipeline and are familiar with the structure of the atomic.events table.
1. Understanding Web Traffic Attribution
What is a Referer?
The HTTP Referer (intentionally misspelled in the standard) header identifies the origin of the request to your webpage. Browsers typically include this field automatically, and it's also accessible via JavaScript (document.referrer).
Example HTTP request:
GET https://www.example.com/ HTTP/1.1
Referer: https://www.google.com/
This tells us the visitor arrived from Google. Snowplow captures this information and stores it in the page_referrer column of the atomic.events table, along with parsed components:
- refr_urlscheme
- refr_urlhost
- refr_urlport
- refr_urlpath
- refr_urlquery
- refr_urlfragment
2. Enabling Referer Parser Enrichment
The Referer Parser Enrichment classifies the referer and populates additional fields in atomic.events:
- refr_medium: Type (e.g., search, social, internal)
- refr_source: Name of the referer (e.g., Google)
- refr_term: Search keywords (if available)
⚠️ Google and other engines now encrypt search terms, so refr_term may often be null.
Configuration Example (referer_parser.json):
{
"schema": "iglu:com.snowplowanalytics.snowplow/referer_parser/jsonschema/1-0-0",
"data": {
"name": "referer_parser",
"vendor": "com.snowplowanalytics.snowplow",
"enabled": true,
"parameters": {
"internalDomains": [
"blog.example.com",
"shop.example.com"
]
}
}
}
Deploy the Enrichment:
./snowplow-emr-etl-runner \
--config config.yml \
--resolver resolver.json \
--enrichments enrichments
3. Campaign Attribution with UTM Tags
While referer data helps identify organic sources, Campaign Attribution Enrichment captures explicitly tagged traffic—typically from paid campaigns—by parsing UTM parameters in the landing page URL.
Example campaign link:
<a href="https://www.example.com/landing/?utm_campaign=launch&utm_medium=cpc&utm_source=adwords">
Click here
</a>
Snowplow parses these into:
- mkt_medium
- mkt_source
- mkt_term
- mkt_content
- mkt_campaign
- mkt_clickid
- mkt_network
Configuration Example (campaign_attribution.json):
{
"schema": "iglu:com.snowplowanalytics.snowplow/campaign_attribution/jsonschema/1-0-1",
"data": {
"name": "campaign_attribution",
"vendor": "com.snowplowanalytics.snowplow",
"enabled": true,
"parameters": {
"mapping": "static",
"fields": {
"mktMedium": ["utm_medium", "medium"],
"mktSource": ["utm_source", "source"],
"mktTerm": ["utm_term", "legacy_term"],
"mktContent": ["utm_content"],
"mktCampaign": ["utm_campaign", "cid", "legacy_campaign"],
"mktClickId": {
"gclid": "Google",
"msclkid": "Microsoft",
"customclid": "My Network"
}
}
}
}
}
✅ Supports multi-parameter mapping—first match takes precedence.
4. Practical Benefits of Combining refr_ and mkt_ Data
While some platforms (e.g., Google Analytics) collapse referer and campaign data into one source field, Snowplow exposes both dimensions explicitly:
- refr_*: Inferred from HTTP headers (organic/search/direct)
- mkt_*: Explicitly tagged traffic (paid/email/referral)
This separation enables:
- Identification of untagged or mistagged campaigns
- Analysis of misconfigured links with no UTM parameters
- Comparison of organic vs. paid performance across channels
- Custom attribution modeling (first-touch, last-touch) using SQL or dbt
5. Best Practices
- Always tag paid campaigns with consistent UTM parameters.
- Configure internal domains to reduce noise from internal referrals.
- Regularly audit enrichment configurations and test them in staging.
- Model touchpoints using Snowplow events in your warehouse
Conclusion
Tracking web campaign performance accurately requires both technical implementation and strategic discipline. With Snowplow's Referer Parser and Campaign Attribution enrichments, you get granular, flexible attribution that is fully customizable to your needs.
Whether you're troubleshooting campaign misattribution or building advanced models in dbt or Spark, Snowplow gives you the foundational building blocks to own your web analytics.