Google Ads

Google Ads: How to Set Up Account-level UTM Parameters

UTM parameters can help marketers track the performance of Google Ads to individual campaigns, ad groups, and keywords. Unfortunately, manually creating tracking parameter strings takes time and is error-prone.

Instead, automate the process. Turn on the account-level Google Click Identifier, set up account-level UTM parameters, and use a script to create ad-group-level custom parameters.

Tracking Parameters

The origin of Google Analytics is Urchin Software Corp., which Google acquired in 2005. Before then, Urchin created a process for tracking clicks on an URL called “Urchin tracking module” — UTM. Google retained that methodology.

Google Click Identifier (GCLID) is Google’s method of passing click info from Ads to Analytics.

Thus the terms “UTM” and “GCLID” describe tracking identifiers — also called “parameters” — which are short snippets of code added to the end of a website’s address. Here’s a sample UTM:

?utm_source=google&utm_medium=ad&utm_campaign=campaign

In the above example, the traffic source is Google, the medium used is an ad, and the campaign is called “campaign.”

The question mark (?) at the beginning of the parameter string appends the website address.

https://example.com?utm_source=google...

An ampersand (&) separates individual parameters.

utm_source=google&utm_medium=ad

GCLID

For companies that use Google Analytics to track ad performance, the Google Click Identifier may be the simplest way to measure ad campaign success. This URL tracking parameter uses a unique code to pass detailed information from Google Ads to Google Analytics.

The GCLID can be enabled at the account level, which means all of the account’s campaigns and ads will include it.

Screenshot of Google Ads admin for account settings.

Auto-tagging Google Ads URLs with the GCLID is one of the most direct ways to pass ad data to Google Analytics.

To turn on GCLID auto-tagging:

  • Open Google Ads,
  • From the account level, select “Settings,”
  • In the drop-down, choose “Account Settings,”
  • Open the “Auto-tagging” section,
  • Select “Tag the URL that people click through from my ad,”
  • Save.

Once turned on, the GCLID will be added to all ad URLs. Here is an example.

?gclid=74974f7hw8hr7ie8wuy

Account Level UTM Parameters

Not all analytics tools, CRMs, and ad-measurement platforms can use or interpret the GCLID. However, these systems can almost certainly parse UTM parameters, which consist of five sections.

  • utm_source describes the ad platform, social media site, or content source of the visit. Examples include “Google,” “Facebook,” or “newsletter.”
  • utm_medium tracks the type of traffic. For Google Ads campaigns, this is often “ad” or “cpc.”
  • utm_campaign is the campaign name or identifier.
  • utm_term captures paid keywords.
  • utm_content indicates something about the ad creative, such as “video” or “search” or something important about the ad, perhaps a target audience.

To create account-level UTM parameters in Google Ads:

  • Open Google Ads,
  • From the account level, select “Settings,”
  • In the drop-down, choose “Account Settings,”
  • Open the “Tracking” section,
  • Paste in a tracking template,
  • Click “Save.”

Tracking template. The key here is the tracking template.

Screenshot of the "tracking template" page in Google Ads admin

The tracking template is the key to setting up account-level UTM parameters in Google Ads.

Let’s consider the template and how it is constructed.

{lpurl}?utm_source=google&utm_campaign={campaignid}&utm_medium=ad&utm_content={creative}&utm_term={keyword}

The first section includes the abbreviation “lpurl” (“landing page URL”) wrapped in curly braces. The braces tell Google Ads that this is a parameter it needs to parse. Specifically, it will replace “lpurl” with the ad’s target URL.

Next are the UTM parameters. Notice that the string starts with a question mark (?) and separates individual parameters with an ampersand (&).

?utm_source=google&utm_campaign={campaignid}...

Google Ads will automatically parse some of these parameters using information about the specific ad, such as a unique campaign identifier.

utm_campaign={campaignid}

The portion of the template for the utm_campaign will output something like this:

utm_campaign=hy76syd6tsgd

Here “hy76syd6tsgd” is the campaign identifier that Google Ads parsed from {campaignid}.

There are several parameter variables, which Google calls “ValueTrack” parameters.

  • {campaignid} is replaced with the campaign id, not the name.
  • {adgroupid} includes the ad group identifier.
  • {device} resolves to “m” for mobile, “c” for computer, and “t” for tablet.
  • {creative} includes a unique id for the individual ad.
  • {keyword} is parsed with the keyword matching the search query or content. This one doesn’t work with dynamic ads.

The template can include additional parameters, such as the device.

?utm_source=google&device={device}

Mix and match these parameters to create an account-level tracking template and test it by clicking the “test” button in Google Ads.

Custom Parameters

The account-level tracking template described above may also include custom URL parameters typically found at the campaign or ad group level in Google Ads.

Screenshot of Google Ads admin for setting up custom parameters in the tracking template

Custom URL parameters are usually set manually at the campaign or ad group level using a familiar name and value pair.

Within the tracking template, these custom URL parameters are wrapped in curly braces and start with an underscore.

?utm_source=google&campaign={_campaign}

If the custom parameter is not set at the campaign or ad group, Google Ads will replace it with a blank. Thus, while you might have expected the parsed URL to look like this:

?utm_source=google&campaign=Amazing_Campaign

It might actually look like this:

?utm_source=google&campaign=

Manually, setting up custom parameters in every campaign or ad group would defeat the whole purpose of this article. Fortunately, this can be done automatically with a Google Ads script which is JavaScript that connects to a Google API within the Ads context.

To create a script:

  • Open Google Ads,
  • Click “Tools & settings” in the upper right,
  • From the drop-down menu, choose “Bulk Actions,”
  • Select “Scripts,”
  • When the scripts page opens, click the plus to add a script.
Screenshot of Google Ads admin section for setting up a custom script

The Google Ads script development environment is several layers deep in the Google Ads platform’s navigation.

Campaign and ad group names. The tracking template described earlier has a couple of shortcomings.

{lpurl}?utm_source=google&utm_campaign={campaignid}&utm_medium=ad&utm_content={creative}&utm_term={keyword}

The utm_campaign parameter will be a campaign id, not a name. Similarly, the utm_content parameter will be an id, not a readable name describing the content. While these ids can be associated with the proper campaign and ad, it would be easier if the names were readable.

So let’s replace these with ad-group-level custom URL parameters. Replace campaignid with the campaign name and creative with the ad group title. Note the changes in the template.

{lpurl}?utm_source=google&utm_campaign={_campaign}&utm_medium=ad&utm_content={_adgroup}&utm_term={keyword}

Here is the script that will capture the campaign and ad group names and add them as custom URL parameters at the ad group level.

function main(){
    let adGroups = AdsApp.adGroups().withCondition("CampaignStatus = ENABLED").get();
    while (adGroups.hasNext()) {
        let adGroup = adGroups.next();
        let group=adGroup.getName().replace(/\s/g,'_');
        let campaign=adGroup.getCampaign().getName().replace(/\s/g,'_');
        adGroup.urls().setCustomParameters({adgroup: group, campaign: campaign});
    }
}

Let’s look at what makes the script work.

Main. The main function is what Google Ads will call each time the script runs. How often that happens can be set from the main scripts page.

Ad groups variable. Next, a variable stores all ad groups associated with the enabled campaigns.

let adGroups = AdsApp.adGroups().withCondition("CampaignStatus = ENABLED").get();

Here the ad groups selector, AdsApp.adGroups(), exposes the ad group level to the script.

Iterator. The next section of the function iterates over the collection of ad groups.

while (adGroups.hasNext()) {
    let adGroup = adGroups.next();
    let group=adGroup.getName().replace(/\s/g,'_');
    let campaign=adGroup.getCampaign().getName().replace(/\s/g,'_');
    adGroup.urls().setCustomParameters({adgroup: group, campaign: campaign});
}

As the script iterates over each ad group, it completes three tasks:

  • Collects the ad group and the associated campaign name,
  • Replaces spaces with underscores in the ad group and campaign name,
  • Adds the custom URL parameter via .urls().setCustomParameters().

Now, each time the script runs, it will add the custom URL parameters at the ad group level. These parameters are then available on the account-level tracking template.

Armando Roggio

Armando Roggio

Bio   •   RSS Feed


x