Google click macros for accurate tracking

Learn how to implement click macros and create redirect chains

Ensuring every ad click is accurately tracked is fundamental to measuring campaign performance and for billing in Authorized Buyers. When your creatives are served through a third-party ad server, this requires the correct implementation of the Google click macro—a dynamic placeholder for Google's tracking URL.

The Google Display Network requires that all certified third-party ad tags that host and serve creatives permit Google to dynamically generate a unique click URL and pass it through the ad tag upon each ad request.

This guide, intended for ad operations specialists and anyone responsible for trafficking third-party ad tags in Authorized Buyers, provides a step-by-step walkthrough on how to properly implement the macro, handle different tracking scenarios, and troubleshoot common issues to ensure reliable click measurement.

In this article

How click tracking works

When a user clicks on an ad, a reliable way to record that event is needed. Because every ad impression is unique, a static, hard-coded URL can't be used. The Google click macro is a placeholder that allows Google to dynamically insert a unique tracking URL for every single ad impression.

Here is a simple overview of the click flow:

  1. User clicks on an ad
  2. Ad tag calls the Google click URL (inserted by the macro)
  3. Google records the click
  4. User is redirected to third-party tracker (if any)
  5. Third-party records the click
  6. User lands on the final destination URL

This process ensures that Google can accurately count clicks, which is vital for billing and campaign reporting.

Implement the standard click macro in your ad tags

For most standard ad tags, the unescaped click macro is all you need.

Macro: %%CLICK_URL_UNESC%%

To implement it, find the parameter in your ad tag that defines the click destination and replace its value with the macro.

At the time of the ad serving, %%CLICK_URL_UNESC%% is dynamically replaced with a unique Google tracking URL.

Example

Before:

<a href="http://my-third-party-ad-server.com/click?ad_id=123&redirect_url=https://advertiser.com"><img src="http://my-third-party-ad-server.com/creative.jpg"></a>

After:

<a href="%%CLICK_URL_UNESC%%http://my-third-party-ad-server.com/click?ad_id=123&redirect_url=https://advertiser.com"><img src="http://my-third-party-ad-server.com/creative.jpg"></a>

Variations: Handling special characters (escaping)

Sometimes, your click-through URL or tracking parameters might contain special characters (for example, &, ?, =). These can break the URL structure. To prevent this, we use escaped macros, which convert special characters into a format that can be safely passed within a URL.

Single-escaped macro: %%CLICK_URL_ESC%%

Use this when your click tracker is being passed as a parameter within another URL. This is the most common scenario after the standard implementation.

For example, when your tag looks like ...&click_url=%%CLICK_URL_ESC%%...

Double-escaped macro: %%CLICK_URL_ESC_ESC%%

This is for more complex cases, such as when your click URL is being passed through multiple redirects or within nested parameters. Use this if your vendor specifically requires double encoding.

Using the unescaped macro inside another URL parameter is a common mistake.

This truncates the URL and causes tracking to fail. Always use %%CLICK_URL_ESC%% when the macro is the value of a key-value pair.

Configure redirect chains for third-party tracking

It is common to have a third-party ad server that also needs to record the click. In this case, you create a redirect chain. You have two primary options:

Option A: Google-first URL (recommended)

This method is generally more reliable for tracking within Google's systems.

  1. Start with the Google click macro.
  2. Append your third-party tracking URL.
  3. Append the final destination URL as a parameter for your tracker.

Structure: [Google Click URL] [Third-Party Click URL] [Destination URL]

Example implementation

%%CLICK_URL_UNESC%%http://my-third-party-ad-server.com/track?redirect=https://advertiser.com

Option B: Third-party-first URL

  1. Start with your third-party tracking URL.
  2. Append the Google click macro (escaped) as a parameter.
  3. Your third-party server is then responsible for redirecting to the Google URL.

Structure: [Third-party click URL] [Google Click URL] [Destination URL]

Example implementation

http://my-third-party-ad-server.com/track?google_url=%%CLICK_URL_ESC%%&redirect=https://advertiser.com

Make parallel requests

Instead of forming a long redirect chain of multiple click URLs, the third-party can redirect the user to their own click URL and then to the destination URL. While the user is being redirected to the third-party's click URL, the third-party makes a separate client-side HTTP request to the Google click URL when the user clicks the creative.

Note: Some Google trafficking tools offer a feature that validates the correct implementation of the Google click URL and that clicks are generated in Google reports. This tool only works when using the click redirect chain methods above, however, so the click validation feature does not work with parallel requests.

Best practices and troubleshooting

  • Always test your creatives: Before launching a campaign, use the creative preview tools to test your click-throughs. Verify that clicks are recorded in both your system and Google's, and that you land on the correct final destination page.
  • Check for discrepancies: Minor discrepancies between Google and a third party are normal. However, if you see major differences, double-check that you are using the correct escaped version of the macro.
  • Consult vendor documentation: Your third-party ad server may have specific requirements for macro implementation. Always refer to their documentation first.
  • HTTPS is a must: Ensure all URLs in your redirect chain use https://.

Further reading and support

Was this helpful?

How can we improve it?

Need more help?

Try these next steps:

Search
Clear search
Close search
Main menu
8975637797493027372
true
Search Help Center
false
true
true
true
true
true
71030
false
false
false
false