Adding URL parameters with Google Tag Manager: Don’t be too literal

thinking monkeyimage from publicdomainpictures.net

Just a quick tip this morning.

Suppose you have incoming traffic that you’d like to track as though the URLs were tagged with UTM parameters. And suppose you use Google Tag Manager to send data to Google Analytics. You might be tempted to tack a query string onto the URL in the “page” field, especially if you’re already doing something to the “page” field (e.g. cleaning out potential PII).

However, you might also find that doesn’t work worth a darn, despite seeing numerous tutorials online that indicate it works great – at least for parameters like search term. In that case, remember that setting the “page” field is but one example of directly setting any field you should so desire – including campaignName (utm_campaign), campaignSource (utm_source), campaignMedium (utm_medium), and any other campaign-related fields that are relevant.

Edited to add: If you are a heavy GA API user like me, it is worth pointing out that the field names you enter into GTM are not the API names (e.g. API pageTitle is just title in GTM). The analytics.js field reference has all of the applicable names.

In short: don’t add UTM parameters to the URL in GTM; add campaign data directly to the pageview GTM sends to GA.

This was a puzzle because searching for help brought up so many irrelevant results. Hat tip to Lunametrics for cracking it for me, once I finally found their post!

Leave a Reply

Your email address will not be published. Required fields are marked *