Skip to content

Instantly share code, notes, and snippets.

@lukebussey
Created October 4, 2016 15:44
Show Gist options
  • Save lukebussey/4666951b5ff727809de22154db09a5e2 to your computer and use it in GitHub Desktop.
Save lukebussey/4666951b5ff727809de22154db09a5e2 to your computer and use it in GitHub Desktop.

Using auto-generated UTM tagged URLs within Google AdWords along with auto-tagging for Google Analytics

The Challenge

You want to use Google AdWords' auto-tagging for a deep integration with Google Analytics, but you need to use UTM parameters with your other analytics and marketing systems, but don't want to manually tag all of your ads.

The Solution

Within AdWords, you can use ValueTrack and custom parameters along with a tracking template to automatically generate a tagged URL with all of the information you need. A tracking template which populates the query string with campaignid, adgroupid and keywork looks like this:

{lpurl}?campaignid={campaignid}&adgroupid={adgroupid}&term={keyword}

Then when someone clicks on one of your ads, {lpurl} will be replaced with your landing page, and the rest of the parameters will be expanded to contain the campaign id, ad group id and keyword.

You can see a list of all parameters and instructions on how to set this up here: https://support.google.com/adwords/answer/6305348

To get the actual campaign and ad content rather than just the IDs which aren't that useful, you need to use custom parameters at the campaign and ad level and then use the parameters like this:

{lpurl}?utm_source=google&utm_medium={ifsearch:cpc}{ifcontent:display}&utm_campaign={_campaign}&utm_term={keyword}&utm_content={_content}

At campaign level you'll need to setup a customer parameter named _campaign containing the URL encoded name of the Campaign, and at the individual ad level, you'll need to setup a parameter named _content containing the URL encoded title of the ad.

For more info on setting up custom parameters, check out this page: https://support.google.com/adwords/answer/6325879

Lastly, within Google Analytics, you'll want to check the following option at the property level: Allow manual tagging (UTM values) to override auto-tagging (GCLID values)

This will allow Google Analytics to merge the auto-tagging data from the gclid parameter with your manual (automatic) tagging.

For more information about the manual override: https://support.google.com/analytics/answer/1033981#override

@rhysrhys
Copy link

Hi lukebussey,

Thanks for this - really useful.

"At campaign level you'll need to setup a customer parameter named _campaign containing the URL encoded name of the Campaign" - Where do I find the URL encoded name of the Campaign? If I enter the custom parameter that matches the name of the campaign in AdWords the data is coming through as two different campaigns, the new one without the Campaign ID..

Thanks,
2017-03-14_1434

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment