Custom variable Google ads

Knowledge base article

Segment Google Ads campaigns by a transaction ID custom variable

4 minutes reading time

Do you have doubts about the accuracy of your Google ads tracking? Want to know which transaction came from which Google Ads campaign? Well you can. There is a way to import specific transaction IDs into Google ads so that you can segment your campaign data by transaction ID. In this article we will look at why it is usefull and how to do it. Let’s go.

Why use transaction ID as a custom variable?

Often, in Google ads, the product that was clicked on, is not the one that the user actually buys. For this reason Google added the cart data tracking functionality to its GTM tags. This will show you which products are bought in what quantity. A great start. But what if you want to match an exact orders to a campaign?

Perhaps you tracking is setup incorrectly and you are having problems with debugging Google ads. Because unlike GA4, you cannot export exact transaction_ids to compare to shop data. That is where this feature comes in. So how do you set it up?

How to send custom variables to Google ads?

In the past it was quite easy to see transaction IDs per campaign only since GA4 and the Google tag things have changed. Luckily there still is a way if you are using server-side GTM. Let me show you.

custom variable gtm
  1. Add your transaction ID variable to the GA4 purchase event tag sending events to your server container. Use a custom name like “order_id” to be able tell the difference between other varaibles.
  2. In the server container, be sure to have a Google ads tag sending the purchase event to your Google ads account.
  3. Also make sure you have a Google ads remarketing tag in your sGTM container.
  4. Add the “order_id” variable from your incoming event data to the custom variables in the server remarketing tag.
  5. Activate the custom variable in the Google Ads UI under goals > custom variables. You can simply click activate when it’s already in the list, if not add it manually.
custom variables in Google ads

Once you have waited a day or two you should see data flowing in. As you can see it can give you the error “event level key detected”. When you hover over it, it tells you “Too few events per value on average. This may reduce the usefulness of reports based on this custom variable. Consider fixing your setup to send coarser grained values.” That means that you are only sending it with a few events and Google recommends you to send the variable with more events. This in the case of the purchase event does not always make sense. But it is worth to check if the value is always available in your server hit.

Now you can segment your campaigns by custom variables to see the result. Go tho the campaign overview, click segment > custom variables and search for your variable. You might see a mix of IDs and “not set” rows.

Reasons why custom variables can be “not set”

As you might see, you can have “not set” values. This can occurs due to a few reasons, namely when:

1. The variable is not present on the conversion action

If a variable is not present on the primary action that is used as a conversion in Google Ads then you will be not set when trying to segment your primary conversion per that variable. If it’s present on some other conversion, like a secondary conversion, add a column All conversions and see if there are values there. If yes, you need to change your setup.

2. The variable is no longer populated

Perhaps your tracking broke and it’s not being send anymore. As seen in the image every custom variable has a recieved time. This means that the last time this variable was populated was then. This also means that if you are segmenting conversion by this variable using recent dates you might see not set since the variable is no longer populated. Debug your setup to see why it is not being send.

3. Consent mode is active

Even when all is set correctly some will remain unpopulated. It is unclear how much exactly but we have seen up to 25% missing variables. Big chance that this is because of consent settings.

So, as you can see, its not 100% bulletproof but it provides you with relevant insight.

Hopefuly it helps. If you encounter any issues, feel free to reach out.

Profielfoto Freek Kampen

By Freek Kampen

Data & Analytics specialist and co-owner of New North Digital. With a background in online advertising, I solve tracking and data issues for entrepreneurs and agencies. Feel free to get in touch!

Related

Continue learning

Looking for more answers?

Check out our knowledge base for more articles and glossary terms. Level up your knowledge with our articles on core concepts in web analytics.

Continue learning
Compare list
Close
Get help

Send us a message