Fixing Google Ads tagging: automating UTMs

If your business uses Google Ads to capture traffic and you use auto-tagging, you have probably experienced some issues with how that traffic is collected in Google Analytics 4. In this post we try to optimize Google Ads tagging by adding UTMs automatically.

1. Origin of the problem with Google Ads tagging

Since July, something is happening with how GA4 reflects the traffic coming from Google Ads campaigns. Specifically, in the campaign dimensions, values such as “(organic)” and “(not set)” appear as the campaigns with more traffic.

Google Ads tagging / Google Ads tagging:
"(organic)" campaigns

Google has not yet been able to resolve the issue, and blames it on Consent Mode:

So while that’s happening, we need to think about a solution that is accurate and scalable. Before we go to it, let’s add a little context.

2. Google Ads auto-tagging

Auto-tagging in Google Ads is a feature that allows tracking parameters to be automatically added to ad URLs. Specifically, Google Ads inserts the parameter gclid (Google Click Identifier) in the destination URL of the ads, which helps to link the traffic coming from Google Ads with other analytics tools, such as Google Analytics.

Advantages of auto-tagging (a priori):

  • Improved attribution: Facilitates more accurate cross-channel attribution in Analytics by having more data on how users interact with ads before converting.
  • Accurate performance tracking: When auto-tagging is enabled, each click receives a unique identifier. This allows conversions and other events to be accurately attributed to the corresponding ad.
  • Synchronization with Google Analytics: The parameter gclid facilitates the integration of data between Google Ads and Google Analytics. Thus, it is easier to analyze the behavior of users on the website after clicking on the ads.
  • Time saving: No need to manually create UTM tracking parameters (and complex nomenclatures and definitions) for each URL, which simplifies campaign management.

Disadvantages of auto-tagging

  • Limited customization control: Unlike UTM parameters, the gclid is not customizable, so there is less flexibility if you need to identify the campaign or source in more detail.
  • Longer URLs: The gclid parameter adds length to URLs, which can affect the appearance of shared URLs and occasionally create problems on platforms with URL length restrictions.
  • To this, we add the recent incident mentioned above.

3. Elements to work with

For this solution we will work with 2 key elements:

URL suffixes: these are parameter strings that are added to the end of destination URLs in ads. These suffixes allow additional tracking information to be added without modifying the main URL. In them, you can enter both parameters with fixed values and custom parameters, which we define below.

Dynamic parameters: these are dynamic tags that you can add to ads, accounts or campaigns. They are configured in the URL options and allow you to define variables that are replaced with relevant values on each click. They usually go between braces and Google Ads provides you with standard dynamic parameters, called ValueTracks: For example,{campaign_id} will be automatically replaced with the Google Ads campaign ID at the time of the click.

There is a small added difficulty. Among the ValueTrack parameters available, there is no {campaignname}, which would make things much easier. If you are lucky enough to have Campaign Manager/Search Ads 360, you can use the parameter {_dscampaign}. If you don’t have it, you will have to invent a new dynamic parameter. {_dscampaign}. If you don’t have it, you will have to invent a new dynamic parameter.

4. Google Ads Hierarchies

Finally, we must take into account the different levels of configuration in Google Ads:

  1. MCC (My Client Center) or Administrator Account: This is the highest level in the Google Ads structure. An MCC allows you to manage multiple Google Ads accounts from a single panel. It is usually used in agencies or companies with multiple accounts.
  2. Accounts: Each Google Ads account includes its own billing settings, payment details and authorized users. This is the level at which you manage specific advertising campaigns for a brand or business.
  3. Campaigns: Within an account, campaigns group ads according to objectives. Each campaign has its own budget, network configuration (search, display, etc.) and targeting configuration (location, devices, etc.).
  4. Ad groups: Within each campaign, ad groups group related keywords and ads around a common theme. This helps to segment ads based on specific topics or types of products/services.
  5. Ads: Ads are the lowest level of the hierarchy and contain the content that is displayed to users, such as text, image or video. Each ad in a group is designed to respond to the keywords in that group and capture the attention of the target audience.
Google Ads hierarchies

5. Google Ads auto-tagging. Levels of action

Let’s go into two specific levels:

1. We will create the URL suffixes at the account level. For each account we have, we are going to include the UTMs, and specifically, for the utm_campaign we are going to add several dynamic parameters, including one that we are going to call {mygacampaign}:

Go to Administrator -> Account Settings -> Tracking and add these parameters in “final URL suffix”:

“utm_source=google&utm_medium=cpc&utm_campaign={_mygacampaign}&utm_id={campaignid}&ad_group_id={adgroupid}&ad_id={creative}&placement_id={placement}&network={network}“

2. We will add this parameter {mygacampaign} at the campaign level. Doing this task manually would take a lot of time and would have a lot of risk of making mistakes, so we are going to automate this part.

How? with Google Ads Script and the Google Ads API;)

6. How does the UTM automation script work?

The parameter {campaignname} is not available in Google Ads ValueTracks, but it is available in the API. Therefore, this script will do:

  1. Review all campaigns in a Google Ads account
  2. If these campaigns do not contain the dynamic parameter {mygacampaign}, it adds it, giving it the value captured by the function campaign.getName().
  3. If there is a new campaign, it will do the same
  4. If an existing campaign is renamed, the value of {mygacampaign} will be updated with the new campaign name.
  5. If an existing campaign does not change its name, then it will do nothing.

The process will be supported by a Google spreadsheet that will collect the campaign names and the values of the parameter {mygacampaign} that have been added/modified.

  • Important note: give the spreadsheet some headers and put a random value in the first row of the first column after the header. This will allow the script to work. You can put “blablabla” if you want.

And all this process will be repeated every hour (the shortest periodicity allowed by Google Ads Script). That is, a maximum of 60 minutes will pass between the creation of a new campaign / campaign renaming and the creation of its tracking parameter that is reflected in the URL suffix that we configure at campaign level.

But this is not all…

7. Bonus track: use Zapier to receive email notifications

Since we launch this script periodically, we can make it notify us of the changes every time this happens and we can check it. In order not to overcomplicate the script with libraries and cumbersome authentications, the simplest option is to generate a Webhook that we will send to Zapier:

Once in Zapier, the configuration is simple: after generating the “capture webhook” trigger, you add a “send outbound email” action, in which you configure the email recipients and the email message.

Zapier. Workflow overview
Zapier. Workflow step 1
Zapier. Workflow step 2

You will receive an email with the changes and a link to the Google spreadsheet to view the changes:

This is what the Google spreadsheet would look like:

1. After the first execution of the script (creation of parameters):

2. After the second execution of the script (I removed the space from two campaign names):

3. After the third – and subsequent – execution of the script (I made no further changes):

And so any of the modified campaigns in Google Ads:

Cool, isn’t it? Here you can download the code:

Just modify the variables“WEBHOOK_URL” with the Zapier url (or other tool) and“spreadsheetUrl” with the Google spreadsheet you have created for the script:

8. Close

It is a bit sad that Google has not been able to provide a solution to this and we have to manually tag. This solution mitigates the operational inconvenience of this. At least we can take solace in the fact that these issues encourage our creativity :)

How have you handled this issue?

Leave a Comment