Do not use blank "campaignId" strings with Google Analytics tags
The short answer was that a blank string had been set as the "campaignId" in the GA tags. Since GA couldn't interpret the blank string, it simply saved the Source/Medium as "(not set) / (not set)".
Special thanks to Jason Packer (@jhpacker in measure.slack.com) for his help here.
This client had a unique way of tracking traffic from campaigns. Instead of adding GA's usual utm_source, utm_medium, utm_campaign, utm_content and utm_term (a.k.a. "UTM tags") to their landing page URLs, the client used a single campaign tracking code. This was inherited from another analytics tool's convention of tracking campaign traffic.
To track the single campaign tracking code in the GA tags, the client made use of GA's relatively unknown "campaignId" field. Through the client's Google Tag Manager, the single campaign tracking code was tracked like this:
- Read the single campaign tracking code from the landing page URL into a GTM variable.
- Use that GTM variable with the "campaignId" field in all GA tags.
The underlying assumption with how GTM variables work is that when the GTM variable does not have a value, then GTM does not set the corresponding field in the GA tag.
For example, let's say a GA tag has Custom Dimension 3 set to a variable, which itself is set from the value of a cookie. But if the user's browser doesn't have that cookie, then the GTM variable gets a blank value, and GTM will simply not set Custom Dimension 3 in the GA tag.
That should have worked with our "campaignId" field too, in the case when the user's landing page URL did not have the single campaign tracking code. But it turns out that GTM didn't follow this assumption.
When the landing page URL did not have the single campaign tracking code (e.g. the user entered the site from an organic search result), GTM would detect a blank string as the single campaign tracking code – and pass it on to GA's "campaignId"!
When GA receives a hit containing a UTM tag or a "campaignId" field, it uses that information to set its Source/Medium report. An explicit campaign tag always overrides the default way of using the browser's referral string, which is how direct traffic, organic search and referrals are tracked.
When GA received these blank string "campaignIds", it didn't know how to deal with them. So it used its default – but not very helpful – "(not set) / (not set)" with the Source/Medium!
So the final solution for the client was this:
- Remove the "campaignId" field from all GA tags.
- Use GA's UTM tags only to track campaigns.
- If the single campaign tracking code must be tracked, then track it to a Custom Dimension instead.
"I've got a blank string, baby,
And I'll write your name."
And I'll write your name."
~ Taylor Swift, "Blank Space" ~
Special thanks to Jason Packer (@jhpacker in measure.slack.com) for his help here.
References:
Comments
Post a Comment