Google Ad Manager Macros every publisher needs to know

Google Ad Manager Macros every publisher needs to know

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.

Macros

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.

Click

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%%http://www.monetizemore.com”>link text</a>

<a href=”http://www.monetizemore.com?rd_url=%%CLICK_URL_ESC%%“>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.

Cachebuster

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.

Conclusion

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 Profesional account at MonetizeMore today!

Kean Graham

CEO and Founder at MonetizeMore

Kean is the resident expert in Ad Optimization covering areas like AdSense Optimization, DFP Management, and third-party ad network partnerships. Kean believes in the supremacy of direct publisher deals and holistic optimization as keys to effective and consistent ad revenue increases.

Get our latest ad optimization tips delivered to your inbox

2 COMMENTS

  1. Emenike Emmanuel

    Hello Kean,

    Thanks for these amazing tips.

    But could be responsible for an ad space going blank?

    I talk about business, not illegal stuff.

    I’m waiting for your response.

    – Emenike

    Reply
    • MonetizeMore

      Could be an issue with the ad units on page (you can check for issues on your page with PubGuru Ad Inspector, our free Chrome extension, see here for details). Alternatively it might be down to targeting issues in Ad Manager, you could try the Ad Manager troubleshooter.

      Reply

Submit a Comment

Your email address will not be published. Required fields are marked *