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.
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%%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.
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.
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).
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.
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 today!