What Are Macros in Google Ad Manager And How To Use Them?

Updated on: December 26, 2023
Google Ad Manager Macros are placeholder strings in creative codes, which can be used to make your ad optimization job much easier. Also, it supports a list of macros that are grouped into 5 categories. So, let's have a look over them in detail.

Simply put, Macros are placeholder strings in creative codes. Google Ad Manager will replace the string with another value or code based on — the creatives, page, setting, etc. depending on the macro in use. It means you don’t have to make changes in the creative code. Though there are several use cases, macros are commonly used as placeholders for destination (click-through) URLs and click-tracking URLs. 

For example, GAM has a macro called Tag for child-directed content — ”coppa=%%TFCD%%”. When you add this macro to any redirect or request for third-party creative, the third-parties can know whether the ad request is coming from a child-directed page. How? If the page has child-directed content, the macro expands to ‘1’. It expands to ‘0’ for other content. 

Google Ad Manager supports a list of macros. You can select them depending on the functionalities you want to add to your creatives. Macros are grouped into 5 different categories — Rendering Macros, Tracking Macros, Video Macros, Video Content Macros, and GDPR Macros. Let’s take a look at them. 

5 Categories of Google Ad Manager Macros

Rendering Macros

They help you to render the creative in an expected way. For example, you can insert the height and width of your creative without manually hard-coding it. Or you can include the click-through URLs for all your custom creatives at once, etc.

Tracking Macros

To help you with accurate tracking and reporting. For example, you can track the clicks on third-party creatives. You can also minimize the tracking discrepancies between GAM and third-party ad servers. 

Video Macros

To include context or content details in your video creatives. It has macros to expand video description URL and video referrer URL parameters.

Video Content Macros

Used for ads that target video content sources (available only to GAM 360 users). These google ad manager macros can expand to video duration, ID, metadata, title, etc.

GDPR Macros

To help you with GDPR compliance. These dfp macros can expand to transparency and consent strings, information about EEA and UK users under the age of consent, request for non-personalized ads, etc.

You can check all the GAM-supported macros on its Help Page.

We have listed some of the most popular and easy-to-use macros to make your work easier. 

Some Useful Macros

Destination URL

To record a click, you might want to redirect the user to a URL before reaching the destination page. This URL is called the creative’s click-through URL. You can use this macro when the click-through URL changes as the creative or template are used across different line items.

There are three different types of destination URL macro – escaped, double-escaped, and unescaped. Learn more about each type here

The type of destination URL macro used depends on the click tracking company. While one company might need escaped URLs whereas others might support unescaped or double-escaped URLs.

Format:

Escaped: %%DEST_URL_ESC%%

Double-escaped: %%DEST_URL_ESC_ESC%%

Unescaped: %%DEST_URL_UNESC%%

Click Tracking Macro

As the name suggests, this macro is used to track the clicks generated from an ad. It expands to a special URL so that you can track the clicks for third-party creatives in Google Ad Manager.

Format:

Unescaped: %%CLICK_URL_UNESC%%

Escaped: %%CLICK_URL_ESC%%

Double-escaped: %%CLICK_URL_ESC_ESC%%

The tracking macro is paired with the click-through URL of the creative in the anchor tag. Use %%CLICK_URL_UNESC%% at the beginning of a link. Use %%CLICK_URL_ESC%% when the click-tracker is the parameter of another URL.

Eg: <a href=”%%CLICK_URL_UNESC%%http://www.google.com“>link</a>

Cachebuster Macro

This macro is used to minimize the impression count discrepancies between Google Ad Manager and a third-party ad server. 

Counting discrepancies can occur when a browser has cached an ad, and it displays the cached file for all the subsequent impressions. When you add the cache buster macro, it’ll generate a random number in the creative code. As a result, it’ll look like a new creative and the browser will make a fresh call to the ad server instead of loading a cached file.

Format: %%CACHEBUSTER%%

File Server Macro

Use this macro when you want your custom creative to call an uploaded creative asset. 

Format: %%FILE:file_display_name%%

You can find the file_display_name in GAM by going to creative details.

Height and Width Macro

This macro can dynamically insert the height and width for a creative during ad serving. It saves your time from hard coding the size of each creative when you want to reuse them with different sizes. It’ll take the appropriate height and width from the “Target ad unit size” field value.

Format: %%HEIGHT%%, %%WIDTH%%

Preview Mode

This macro can help you in avoiding counting discrepancies caused while previewing creatives. When you view a creative as an Ad Manager preview, this macro will expand to ‘true.’ In this way, your backend system and other third parties will easily understand that the impression took place in preview mode. So, they won’t count it.

Format: %%PREVIEW_MODE%%

How do you add the macros to your creatives?

Adding macros to the creatives is simple. Follow these steps:

  • Sign in to GAM.
  • Go to Delivery > Creatives.
  • Go to Add Creatives.
  • Select the desired advertiser and click Continue.
  • Select Third-party.
  • Add a creative name.
  • Choose the type of code snippet.
  • Add the creative code once the creative is added. 
  • Select Insert Macros.

What’s Next?

Macros can help you in many ways when you are dealing with third-party creatives. But take the help from experts while using them. Also, remember that all macros are case-sensitive. So, keep the case in mind while you are referring them from Google’s help page.

News and Tips for Publishers

Get the inside scoop on publishing and programmatic with our 5-minute newsletter.