Google Ad Manager Macros every publisher needs to know

DoubleClick For Publishers / Google Ad Manager Ad Optimization
Last updated: September 6, 2021 | by Kean Graham
Google Ad Manager Macros every publisher needs to know

This post was most recently updated on September 6th, 2021

Macros in Google Ad Manager (GAM) are values or short sections of code placed inside creative codes. To humans, they look like short phrases encased in double percentage signs, but when GAM reads them, it knows to run small sections of pre-defined code.

These macros can be placed inside the GAM tag, inside the creative tag (third party or custom creatives), or in click-through URLs. They take the format ‘%%MACRO_NAME%%’, and they are case sensitive. The common practice is to stick to uppercase letters in all macro names. Here are some macros every publisher needs to know that will surely make the task of optimizing their ads easier.


Destination URL

Three types of macros deal with destination URL: unescaped (%%DEST_URL_UNESC%%), escaped (%%DEST_URL_ESC%%), and double-escaped (%%DEST_URL_ESC_ESC%%). Which of the three you need usually depends on the third-party click-tracking company, but all three macros expand to insert the creative’s click-through URL.

The ‘click=’ string will often indicate the type to use: ‘click=:’ or ‘click1=:’ for escaped, ‘click0=:’ for unescaped and ‘click2=:’ for double-escaped.


As with destination URL, click-through URL can be escaped and unescaped. %%CLICK_URL_UNESC%% goes at the beginning of a link after the href command. If the click tracker is part of the parameters of another URL, use the escaped macro as shown below:

<a href=”%%CLICK_URL_UNESC%%”>link text</a>

<a href=”“>link text</a>

To verify in GAM, preview the creative and then click on its preview. GAM will display a confirmation if the macro is working.

View URL

To enable GAM to count when impressions are viewed rather than served, %%VIEW_URL_ESC%% or %%VIEW_URL_UNESC%% is used. This macro is intended for out-of-page creatives. You can deploy it in various ways, but Google recommends it should be deployed as follows:

<img src=”%%VIEW_URL_UNESC%%” style=”display:none”>

Upon viewing, the ad requests a dummy 1×1 image, which should be kept hidden to avoid distorting the page layout.

Height and width

These are useful when creating a template for a creative that you want to reuse. Instead of hard-coding the sizes into the creative, use %%HEIGHT%% and %%WIDTH%% for the sizes. The height and width are filled by the ‘Target ad unit size’ value defined in GAM.

Child-directed content

The macro %%TFCD%% (using the format ‘coppa=%%TFCD%%’) in a request will indicate to third parties that the request comes from a page with content intended for children, to help with compliance with the Children’s Online Privacy Protection Act (COPPA).

URI encoding

If you use a variable in your creative template whose value contains or could contain non-standard or reserved characters, the URI encoding macro will help you encode these characters. The best example is the landing page. If you were to pass a landing page containing query parameters (including ‘?’ or ‘&’) that URL might become corrupted, and the user might not be sent to the correct place. The format of this macro is slightly different. To encode the landing page, you would use ‘[%URI_ENCODE:landing_page%]’ where ‘landing_page’ is the name of the variable.


The cache buster aims to reduce discrepancies in impression counting by ensuring that each time the creative sees a request, a new call is sent to the ad server (rather than a cached copy of a previous request). This macro is needed in cases where the third party’s code does not include such provision, but when it does, most third parties will consist of some indication of where the cache buster macro should be placed, if so desired.

The macro is written as %%CACHEBUSTER%% and will give the same random number to all events in that creative so that events can be tied to the same request/response.

Preview Mode

The preview mode macro &&PREVIEW_MODE%% will give a result of true if the creative is being shown in the preview mode of GAM, and false if not. Using this in the creative code stops the counting of preview impressions and artificially inflating the impression totals.

Video description URL

These macros expand to the description URL (typically identical to referrer URL).

Use %%DESCRIPTION_URL_ESC%% (single-escaped) when the macro is inside a URL and %%DESCRIPTION_URL_UNESC%% (unescaped) elsewhere.


Using these macros in your daily ad optimization work will make life a lot easier. If you don’t understand nor want to spend time learning macros, why not let our ad ops specialists handle it all for you? We help hundreds of publishers to optimize their ad inventory for maximum ad revenue. Let us do the same for you. Sign up for a Professional account at MonetizeMore today!

Ad Ops Tips & Guides, Industry News, Latest Tech and Success Stories - right in your inbox.

We are committed to protecting you Privacy Data

Here’s the course that 300+ pubs used to scale their ad revenue.

Enroll today

Book Banner

"Working with MonetizeMore has been a transformative experience as they helped to increase my overall revenues by over 180%"


Paid to Publishers


Ad Requests Monthly


Happy Publishers

Recommended Reading

Ad Optimization
March 27, 2023

The Top 5 Ad Sizes That Generate the Most Revenue in 2023

Read More
March 22, 2023

The Ups and Downs of ChatGPT for Publishers| Maximize Your Revenue…But at What Cost?

Read More
Traffic Cop
Last updated: March 22, 2023

The High Cost of Fake Traffic: $143 Billion Gone

Read More

Trusted by 1,500+ publishers worldwide

10X your ad revenue with our award-winning solutions.

Let's Talk

Ready to 10X your ad revenue with the #1 ad management partner?

Start Now