You are here: Publishers > Macros > How to insert OpenX macros

How to insert OpenX macros (Publishers)

Last updated June 6, 2016

You can manually insert OpenX macrosFor OpenX, a command enclosed in curly braces {} that dynamically inserts attributes into your HTML or third-party ad creatives and click-through URLs when OpenX serves an ad. Other macros, like from your video player, may have alternate formatting. into your HTML ads, third-party ads, and click URLs. In addition, OpenX can automatically insert OpenX macros into your third-party ad tags.

Inserting an OpenX macro into a URL

The following example shows how to manually insert a macro into a click-tracking URL.{}

In this case, OpenX automatically replaces {} with the OpenX ID for the selected ad that OpenX serves. You may also want to consider the {} macro for a click-tracking URL.

Manually inserting an OpenX macro for cachebusting

Insert a random number into an ad tagA small piece of code that defines the ad space where ads display on a website. It includes parameters that describe the inventory advertising campaigns can target, which may in turn display ads in the ad space. so that the end user's browser won't reuse an ad that has already been displayed and cached. This is called cachebusting. This technique helps maximize your inventoryAd space available on a website or app. The basic unit of inventory for OpenX is an ad unit., and helps minimize discrepancies between publisherAn account type that represents a business with ad space to sell. and marketer delivery reports.

Use the following example as a reference for inserting a macro into an ad tag for cachebusting.

<img src="{random}"/>

OpenX automatically replaces {random} with a random, ten-digit, alphanumeric string.

Manually inserting a custom variable in an HTML ad creative

Use the following example as a reference for inserting a macro for a custom variable into an HTML ad creativeThe media asset associated with an ad, such as an image or video file..

<h1> Hello {} </h1>

In this case, OpenX automatically replaces {} in the HTML ad creative with the actual value of the custom variable passed in the ad requestCommunication from a web browser or app to an ad server to display an ad.. For example, if an ad tag contains, then if you place the {} macro in your HTML ad creative as in the preceding example, when OpenX serves the ad, it replaces the macro with the actual value from the request, as follows:

<h1> Hello mulligan </h1>

Manually inserting an OpenX macro in a third-party click URL

If you are using an unsupported third-party ad tag, use the following example as a reference for inserting a macro into a third-party click URL.

Consider the following existing third-party ad tag:

<a href="">
<img src="[replace_with_random_number]">

When creating your ad in the OpenX UI, enter the value of the href link in the Click Tracking URL field and then replace the URL with {clickurl}. You can also use the {random} macro for cachebusting:

<a href="{clickurl}">
<img src="{random}">

The output of the tag that is now using the {clickurl} and {random} macros might look like the following:

<a href="">
<img src="">

In this case, OpenX replaces {clickurl} with the click URL value from the HTML source code for the selected ad that OpenX serves, which redirects through OpenX to track clicks, and then redirects to the next URL value in the string. The {random} macro is replaced with a random number, which

See also

Supported macros

This topic applies to Ad Server. This topic applies to Ad Exchange. This topic applies to SSP. Most SSP activities are completed by OpenX.

Feedback form