Google Ad Manager

What are Macros in Google Ad Manager?

Macros, as developers would know, are a small sequence of characters that expand into a big block of code. The character sequences or strings invoke a pre-defined code. While not exactly so, you may think of Macros as hyperlinks of the programming world.

If there are common command sequences that need to be invoked for different applications, coding them every time does not make sense. They help run the same code with changed variables.

Using macros reduces the scope of error and makes programming less tedious. 

Macros in Google Ad Manager: How Does it Work?

In Google Ad Manager, a great number of functions need to be performed when an ad is shown and after it is seen by the user.

The macros are placed in the creative tag or the click-through URLs. It allows the publisher or the advertisers to perform a specific function by invoking a code.

Even as these functions vary across sites, these are drawn from a common set. For example, tracking clicks, impressions, video views or customizing ads based on gender or location of the user are functions that most advertisers use.

How to Spot Them?

Found within two percentage symbols on either side, macro names are usually written in uppercase; it looks like %%MACRONAME%%.

It can be found in any code executed by the ad server while serving the ad: click-through URLs, third-party or custom creative code, or ad tags.

What are the Different Types of Macros in GAM?

While the Google Ad Manager support pages list around 40 different Macros, these can be grouped in the following five different types or categories.

  1. Rendering Macros – to ensure creatives are rendered correctly both in form and function
  2. Tracking Macros – for tracking and reporting performance on various parameters like clicks, impressions
  3. Video Macros – carrying details about content or context
  4. Ad request macros – including those which are subject to GDPR
  5. VAST tracking macrosVAST refers to Video Ad Serving Template. Macros help structure ad tags and collect metadata when tracking event on a video player

Two of five – Ad request and VAST tracking – are macros for Dynamic Ad Insertion.

In this article, we will focus on a few popular and commonly used macros. For the full list, you may refer to the Google Ad Manager Help on Macros.

Examples of GAM Macros

Let’s start with simpler ones and move on to the more complex ones. 

1. Height and Width Macro 

Display sizes vary across different ad units. Hardcoding the size into every creative is not only time-consuming but also error-prone. A Height and Width Macro dynamically inserts the size values based on the target ad unit size during ad delivery.

These are represented as %%HEIGHT%% and %%WIDTH%%.

2. Destination URL

Typically, as a creative or template appears in different line items, the click-through URL changes.

If you wish to include the click-through URL of the creative into the creative code, you use the destination URL macro. The macro expands to the creative’s click through URL. 

There are three types of destination URL macros based on the amount of escaping, which depends on the third-party click tracking company. 

  1. Escaped – %%DEST_URL_ESC%%
  2. Double-escaped – %%DEST_URL_ESC_ESC%%
  3. Unescaped – %%DEST_URL_UNESC%%

For the uninitiated, Escaping is the practice of substituting a character (or a series) to represent another. 

As URLs can only be transmitted over the internet via the ASCII character set, other characters are encoded during transmission. 

For example, the character ‘?’ when single escaped (encoded once) is represented as %3F; when double escaped (encoded twice) it appears as %253F in URL. 

You can play around and find more such representations of non-ASCII characters on any online URL encoding tool.

3.  Cachebuster 

A cachebuster helps count the number of impressions more accurately. Every time the code is executed, a new call is made to the server. 

Not adding a cachebuster leads to incongruence in impression count between Google Ad Manager and third-party server. However, adding it isn’t mandated by all third parties; some have it, others don’t.

Creative vendors provide a placeholder for adding a cachebuster macro, like [RANDOM_NUMBER] in the below example:

http://example.3rd-party-adserving.com/Targeting/;adServer.php?ab=cd&e=12fg=click&ord=[RANDOM_NUMBER]

When you add a cachebuster macro, it becomes:

http://example.3rd-party-adserving.com/Targeting/;adServer.php?ab=cd&e=12fg=click&ord=%%CACHEBUSTER%%

4. Click

Click macro is used for tracking clicks on third-party creatives in Ad manager. 

Similar to destination URL macro, click is available in three types based on the amount of escaping:

  1. Escaped – %%CLICK_URL_ESC%%
  2. Double-escaped – %% CLICK _URL_ESC_ESC%%
  3. Unescaped – %% CLICK _URL_UNESC%%

While implementing click tracking URL and destination URL together, you need to ensure you are doing it right. They need to be sequenced correctly. Not doing so, you may encounter HTTP 404. Read more about it here.

5. Viewed Impression

A viewed impression macro helps Ad manager count the number of impressions of out-of-page creatives. These include pop-up, pop-under or floating creatives. 

As soon as the creative downloads and starts loading on the user device, an impression is counted. It is of two types:

  1. Escaped – %%VIEW_URL_ESC%%
  2. Unescaped – %%VIEW_URL_UNESC%%

Implementing Macros

Google Ad Manager helps you insert macros automatically in a few clicks. However, it can be done automatically for creatives from select vendors. 

At the time of writing this article automatic insertion is available for 138 vendors. Check the full list here.

Here’s how you do it in GAM:

  • Sign in to your Google Ad Manager account.
  • Click on Delivery >> Creatives
Google Ad Manager macros
  • Select Add Creatives
Google Ad Manager macros
  • Type the advertiser name whose creative you’re adding and click on Continue
  • Click on Third-party
  • Enter a name for the selected creative
  • Select the option for adding a code snippet for AMPHTML ads, standard ads, etc.
  • Once the third-party creative is added, insert creative code from the vendor list specified above.
  • Click on Insert Macros

Important: If you’re unable to view the Insert Macros button, it means that Google Ad Manager is not able to recognize the creative. 

Things to Remember while using Macros

Using macros help you save time and effort when dealing with a plethora of permutations and combinations of a sizeable number of creatives. It makes daily ad optimization a breeze.

However, we highly recommend you use a technical resource if you aren’t comfortable dealing with lines of code. Helps keep things smooth!

As a publisher, if you have to serve third-party creatives with reduced discrepancies, you need to take great care in inserting macros in the third-party code.

Unless you wish to customize the code yourself, do not enter the third-party tags as custom creatives. 

A better approach would be to use third-party creatives whose code and vendor Ad Manager recognizes. It makes your job easy and relatively error-free, as the Ad Manager automatically inserts the right macros in a few clicks.

If you wish to read more about Macros make sure you check the Google Help Center.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.