Skip to main content

Campaign attribution enrichment

This enrichment can be used to link events to marketing campaigns, using the query string parameters.

When using online marketing campaigns to drive traffic to our website, it is usually possible to find information in the query string parameters to identify the particular campaign, medium and more.

A link for an online advertisement that brings users back to our site might look like:

https://www.acme.com/spring_offer_product?utm_source=influencer&utm_medium=blog&utm_campaign=spring_offer

This could result in the following fields being added to the enrich event:

fieldvalue
mkt_sourceinfluencer
mkt_mediumblog
mkt_campaignspring_offer

The configuration of the enrichment defines which parameters in the URL (e.g. utm_source) map to which fields in the event (e.g. mkt_source) — see examples below.

In addition, this enrichment automatically knows about Google (corresponding to the gclid query string parameter), Microsoft (msclkid), and DoubleClick (dclid). For example, if the query string contains &gclid=abc, this will be the result:

fieldvalue
mkt_clickidabc
mkt_networkGoogle

Configuration

Testing with Micro

Unsure if your enrichment configuration is correct or works as expected? You can easily test it using Snowplow Micro on your machine. Follow the Micro usage guide to set up Micro and configure it to use your enrichment.

Basic usage

Here’s an example for standard Google parameters. It specifies that the utm_medium parameter in the query string will map to the mkt_medium field in the event, and so on.

    "parameters":{
"mapping":"static",
"fields":{
"mktMedium":[
"utm_medium"
],
"mktSource":[
"utm_source"
],
"mktTerm":[
"utm_term"
],
"mktContent":[
"utm_content"
],
"mktCampaign":[
"utm_campaign"
]
}
}

And here’s an example for Omniture (only the mkt_campaign field will be populated):

    "parameters":{
"mapping":"static",
"fields":{
"mktMedium":[
],
"mktSource":[
],
"mktTerm":[
],
"mktContent":[
],
"mktCampaign":[
"cid"
]
}
}

Supporting multiple parameters

What if some of your links use utm_campaign=... and some use legacy_campaign=...? In this case, you can configure more than one parameter name in the array, like so:

    "parameters":{
"mapping":"static",
"fields":{
...
"mktCampaign":[
"utm_campaign",
"legacy_campaign"
]
...
}
}

The same applies to other configuration options, namely mktMedium, mktSource, mktTerm and mktContent.

note

If the query string includes multiple acceptable parameters (e.g. both utm_campaign and legacy_campaign), the first one listed in the configuration will be used (not the first one present in the query string).

Results:

query stringvalue of mkt_campaign
utm_campaign=abcabc
legacy_campaign=abcabc
legacy_campaign=abc&utm_campaign=defdef

Click and network attribution

You can define which URL parameters are used to populate the mkt_clickid field (the defaults include gclid, msclkid and dclid). For each parameter, the same configuration setting also defines what network — the mkt_network field — it corresponds to (by default, gclid corresponds to Google, msclkid to Microsoft and dclid to DoubleClick).

tip

You can configure any parameter names or network names, including your custom ones.

In the next example, we will customize the mktClickId configuration:

  • First, we add support for wbraid and gbraid parameters, which will be mapped to Google as the corresponding mkt_network.
  • Second, we override the msclkid parameter, so that it maps to NotMicrosoft as the marketing network (instead of the default Microsoft).
  • Third, we add a custom xyzid parameter that maps to the XYZ network.
  • Other default mappings for gclid and dclid remain unaffected.
    "parameters":{
"mapping":"static",
"fields":{
...
"mktClickId": {
"wbraid": "Google",
"gbraid": "Google",
"msclkid": "NotMicrosoft",
"xyzid": "XYZ"
}
...
}
}
caution

You should not use more than one click parameter in the query string (e.g. both wbraid and gbraid). If you do, one of them will be picked arbitrarily.

Results:

query stringvalue of mkt_clickidvalue of mkt_network
wbraid=abcabcGoogle
msclkid=abcabcNotMicrosoft
xyzid=abcabcXYZ
wbraid=abc&gbraid=defabc or def ⚠️Google

Output

This enrichment populates the following fields of the atomic event :

FieldPurpose
mkt_mediumThe advertising or marketing medium, for example: banneremail newsletter.
mkt_sourceIdentifies the advertiser, site, publication, etc. that is sending traffic to your property, for example: newsletter4billboard.
mkt_termIdentifies keywords (terms).
mkt_contentUsed to differentiate similar content, or links within the same ad. For example, if you have two call-to-action links within the same email message, you can use mkt_content and set different values for each so you can tell which version is more effective.
mkt_campaignThe individual campaign name, slogan, promo code, etc. for a product.
mkt_clickidClick ID which resulted in the redirect/follow request
mkt_networkThe advertising network name, either default determined from parameter for Click ID or custom specifically stated

If the enrichment is not activated, those fields will not be populated.