Ad Server Macros: Easy to Learn, Easy to Master


Updated on: January 16, 2024

Published on:

Great things are done by a series of small things brought together. And that's what Macros are all about. Join me to explore the big wonders brought by these small packages in the ad tech industry.

Do you know how things you use work?

In today’s digital world, publishers who understand the basic code logic of their software are seen as highly professional and ahead of the curve.

This article will familiarize you with the concept of “ad server macro.” We’ll explain what it is, how it communicates with an ad server, its main types, and how difficult it is to set up macros in an ad server.

What Are Macros?

Macros are like shortcut codes that add extra information to the creative code. They save you from changing the whole creative code whenever you want to update something. In professional terms, they are called placeholders or special strings in the creative code. 

These placeholders (pieces of code) are replaced by certain values when run. They typically look like $$MACRO_NAME$$ and can be inserted in the banner’s URL or HTML сode fields.

$$MACRO_NAME$$ isn’t the only way to write macros. Every platform has its syntax, so, for example, they could also have brackets  $${MACRO_NAME}$$.

Now, you ask what’s a creative code, or some might wonder, “Is it the same as an ad tag”.

  • An ad tag is a piece of code that calls the server to ask for ad content (pics, text, etc.). 
  • A creative code is a piece of code publishers get from advertisers to show a particular ad. It tells a website how to show an ad. 
  • A macro enables this creative/ad content to be updated as per the real-time requirement. 

*Fun fact: A macro can be part of ad tags, and both don’t affect the primary functions of each other.

What Are Ad Server Macros?

Like any other macros, ad server macros are also shortcut codes but are specific to the tasks that an ad server does. The ad server uses them to make quick and smart decisions about showing ads. 

Let’s understand with an example:

Your websites cover all travel-related topics like – destination, best deals, reviews, and travel tips. Your ad slots display ads from travel agencies, airlines, and hotel chains. You can use a macro like “[Destination]” in the creative code for the ad slots. This macro will act as a placeholder to show ads relevant to the article’s topic.

So, a reader is reading your article on “Best Beaches in Hawaii”. The ad server sees the macro “[Destination]” in the creative code and then replaces “[Destination]” with “Hawaii” and shows an ad for a travel package to Hawaii.

Benefits of Ad Server Macros for Publishers

Apart from content matching, ad server macros can also help you with

  • Tracking – You can use a tracking macro like “[Click_ID]” to track each click on the ad, helping you decide the efficiency of the ad.
  • Geo-targeting – A macro like “[User_Location]” can show location-specific ads. If the visitor is from New York, the ad server could show an ad for a New York-based grocery delivery service.
  • Time-stamping – A macro like “[Time_Stamp]” can record when an ad was clicked or viewed, helping you understand when your audience is most active.
  • Dynamic Sizing – With the help of macros, you can make an ad fit on different slots on your website. So, a single creative can be used multiple times.
  • Real-time updates – Some macros can update parts of an ad in real-time. For example, a weather-related ad could show the current temperature based on a macro that pulls this information.
  • Track Conversions – You can use macros to track what kind of actions users take after clicking on an ad. This helps you analyze the revenue generation potential of your ad slot.

These are only some of the many benefits of using macros. 

How to Set up Macros in Different Ad Servers?

That was a lot of theory, and now it’s time to figure out the main use cases of ad server macros. 

Adding macros shouldn’t differ greatly from the software you use. After all, you simply put $$SOME_STUFF$$ to the URL/HTML.

In Epom ad server, for example, this looks the following way:

Epom Server

So, finally, why do we need ad server macros? The answer: dynamic data exchange between all participants of a direct deal

Specifically, there are two main use cases:

  1. Publisher provides data to an ad server.
  2. Ad server provides data to an advertiser.

[Case_1] The ad server wants to know something about the user but can’t. The publisher, however, has this information and wants to share it.

Let’s imagine a scenario: the user scrolls the football news website, catches a glimpse of the news piece about his favorite team – Chelsea – and clicks on it.

This news piece contains the ad server’s HTML5 code. Our code doesn’t know that it tells about Chelsea, but you do. We really need to know this info for better targeting of hypothetical Chelsea fans and selling ads more expensive to hypothetical Chelsea owners.

For this, let’s add your macros to our code. It will look something like this:

<ins> class=“67536869” data-key=“8c8f1d6f7e2e1910158e54fc9c735926″ data-cp-team=“##some_custom_parameter_which_publisher_will_fill_in_with_team_name##“</ins>

Surely, to make this work, you would need to create a logic with which your site understands the team name in the news piece. But in the end, both the ad server and you will have a new targeting parameter.

[Case_2] The advertiser needs transparency in the way you and the ad server work. For this, we need to put  $$PUBLISHER_NAME$$ into a link the advertiser provided to the server client. The default link looks something like this:{PUBLISHER_CLICK_ID}&source={SUB_PUB_ID}&gaid={GAID}&idfa={IDFA}&pub_name={PUB_NAME}&

The variables before the brackets (pub_name=) are called parameters. The stuff in the brackets are values.

Let’s change the value {PUB_NAME} to a macro $$PUBLISHER_NAME$$. The modified link looks like this:{PUBLISHER_CLICK_ID}&source={SUB_PUB_ID}&gaid={GAID}&idfa={IDFA}&pub_name=$$PUBLISHER_NAME$$&

Now, every time the ad is shown, the parameter pub_name will provide the advertiser with the name of the publisher who shows this ad.

Note: the above is just for Epom. Things will be different for setting macros in Google Ad Manager or any other ad server. 

One Step Closer to Proficiency

Ad server macros are an inherent part of the advertising process that could be used for any party. We hope that with this handy guide, you’ll understand ad serving a bit better and get one step closer to enlightenment.


News and Tips for Publishers

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

Related Read