Macros for custom creatives

Learn to use escaped and unescaped macros

This article describes how to use macros in custom creatives, especially click-through and click-tracking URLs. There are different macro variations (unescaped, escaped, double-escaped) to ensure characters are interpreted correctly when inserted into URLs. Using the wrong variation can lead to errors and users not being directed to the intended landing page.

On this page:

Technical expertise

This article is for users who develop custom creatives and requires technical expertise.

If you're a trafficker who is expected to associate a custom creative with a line item, but don't have technical expertise to troubleshoot custom creatives, find a resource who does. This might a person at your organization, who created the custom creative in Ad Manager, or a resource at a creative agency who provide your organization with the code used in the custom creative.

Macros are used in custom creatives for a variety of purposes. Two important purposes are as placeholders for destination (click-through) URLs and click-tracking URLs. These come in unescaped, escaped, double-escaped varieties.

Escaping is the practice of using one character (or a series of characters) to represent another character. URLs can only be transmitted over the internet via the ASCII character-set. However, characters outside of this set can be used in URLs, so those characters must be encoded during transmission to be interpreted correctly.

In developing custom creatives, you need to use one or more of the following in the creative code:

  • Unescaped click-tracking URL: %%CLICK_URL_UNESC%%
  • Escaped click-tracking URL: %%CLICK_URL_ESC%%
  • Unescaped destination URL: %%DEST_URL%%
  • Escaped destination URL: %%DEST_URL_ESC%%
  • Double-escaped destination URL macro: %%DEST_URL_ESC_ESC%%

To ensure that clicks are tracked or that users get to the destination URL, you need to use the appropriate variant. Using the wrong variant could mean click-tracking fails to record or that users don't reach the destination URL. 

If both click-tracking and click-through URLs are required, you need to additionally ensure that the macros are sequenced or "chained" together correctly using the right variants.

In this article, you can review correct and incorrect examples of how to use destination and click-tracking URL macros and how to chain them together.

Example macro insertions

Here's an example of an unescaped click-tracking URL from Campaign Manager 360. Parameters have been removed or shortened for clarity:

http://adclick.g.doubleclick.net/aclk?sa=l&ai=C8qeK&adurl=

Compare this URL with escaped version of the same URL:

http://adclick.g.doubleclick.net/aclk%253Fsa%253Dl%2526ai%253DC8qeK%2526adurl%253D

Here, reserved characters have been double-escaped using percent-encoding. For instance, question marks (?) are always represented by the sequence of characters %253F, while the equal signs (=) are always represented by the sequence of characters %253D.

Creative preview and testing macros

Testing ad creatives ensures that they behave as intended. Since macros are placeholders, and since there's sometimes complex code involved, the best way to test a custom creative is by previewing the creative from the line item. To do so:

  1. Open the creative in a new window.

    JavaScript doesn't function in the preview available directly in Ad Manager. In addition, macros can't be viewed in their expanded version.

  2. Use your browser's development tools ("dev tools") to inspect elements and the DOM.

Validate click-tracking macros

When the macros are inserted properly, clicking the creative from the preview leads to an Ad Manager landing page. This page confirms the click has been tracked. You are then be redirected to the destination URL page associated with the creative.

If either of these things don't happen, there's a problem with the macros or how they were chained together. 

Validate view macros

Validating impression-tracking macros requires the use of a traffic analyzer. A traffic analyzer allows to view and capture HTTP requests. Some browser dev tools include a tool of this kind. There are also third-party traffic analyzer software available.

Using a traffic analyzer, inspect the HTTP requests when the ad creative loads. You're looking for a successful request or "ping" to the server that records the impression. Note any HTTP errors during HTTP requests.

  • If you don't spot any errors, and you can see a successful ping of the server that records the impression, macros have been correctly configured.
  • If you spot any errors, return to the source code of your custom creative to troubleshoot. A common error code when macros are placed incorrectly is HTTP 204.

Was this helpful?

How can we improve it?
true
Release notes

Read about the latest Ad Manager features and Help Center updates.

See what's new

502023359661179059
true
Search
Clear search
Close search
Main menu
Search Help Center
true
true
true
true
true
148
false
false
false
false