Link Search Menu Expand Document

PDF

Passing Macros in Bid Responses

Demand Partners

Last updated on September 27, 2018


on this page


OpenX macros are commands that dynamically insert attributes into your HTML or third-party ad creatives and click-through URLs when OpenX serves an ad. To use OpenX macros, enclose each macro key in curly braces {} and insert it into the corresponding source code. For example, {clickurl}.

NOTE

OpenX will not replace macros that have been URL encoded. Additionally, if you use a macro for which OpenX is unable to find a replacement value, OpenX ignores the macro and leaves it in place in the ad creative or click URL.


Supported Macros

OpenX supports the following macros for OpenRTB buyers, which you can include in the ad markup field (adm) for each Bid object in your bid response. OpenX automatically and dynamically replaces each macro with the value specified in the following list before the ad is sent to the end-user. OpenRTB-specific macros are expressed as ${MACRO_NAME}.


Price macros

OpenX supports the following price macros:

MacroIs replaced with
${AUCTION_PRICE:[OXCRYPT](#price-encrypting-scheme)}The price of the won impression expressed as an encrypted value in CPI micros in the same currency as the bid. In adm, ${AUCTION_PRICE:OXCRYPT} is supported, but ${AUCTION_PRICE} is not.
{WINNING\_PRICE} or {winning\_price}The winning price of the auction sent as an encrypted value in CPI micros of your account currency. For example, a CPM of $1 = 1,000 CPI micros = 1,000,000 CPM micros.

The price is passed as unpadded web-safe base 64 encoding (per RFC 3548). You must convert this to standard base 64 encoding and pad the result. The price is decrypted with the encryption key, and the integrity of the price is verified with the integrity bits and the integrity key.

OpenX emails the encryption and integrity keys to you during your onboarding and account setup. You also can copy them from the right-side Summary panel of your Real-time Bid Settings page.
The message format is: init_vector (16 bytes), encrypted_price (8 bytes), integrity (4 bytes).

OpenRTB-specific macros

OpenX supports the following OpenRTB macros (expressed in fields as ${MACRO_NAME}):

MacroIs replaced with
${AUCTION_BID_ID}The ID of the bid as specified in the BidResponse.bidid field.
${AUCTION_CURRENCY}The currency for the corresponding winning auction price.
For example, “USD”
The advertiser’s OpenX Ad Exchange account currency is used with this macro.
${AUCTION_ID}The ID of the bid request as specified in the BidRequest.id field.
${AUCTION_IMP_ID}The ID of the impression as specified in the BidResponse.seatbid.bid.impid field .
${AUCTION_PRICE:OXCRYPT}The price of the won impression expressed as an encrypted value in CPI micros in the same currency as the bid. In adm (the ad markup field), ${AUCTION_PRICE:OXCRYPT} is supported but ${AUCTION_PRICE} is not.
${AUCTION_SEAT_ID}ID of the bidder seat for whom the bid was made.

Click macros

Implement at least one click macro from the following table. OpenX requires click macros to provide valid performance data that helps you purchase more effective inventory.

NOTE

The number of characters in the tracking URL that is returned when a user clicks an ad has been reduced, making this information easier to use and integrate.

MacroIs replaced with
{clickurl}The unencoded and time-sensitive URL for the selected ad that OpenX serves, which enables click tracking.
For example, http://ads.example.com/w/1.0/rc?ts=555YADAYADA555&r=
{clickurl_dbl_enc} or {clickurl_dbl_esc}The double-encoded and time-sensitive URL for the selected ad that OpenX serves, which enables click tracking.
For example, http%253A%252F%252Fads.example.com%252Fw%252F1.0%252Frc%253Fts%253D555YADAYADA555%2526r%253D
{clickurl_enc} or {clickurl_esc}The encoded and time-sensitive URL for the selected ad that OpenX serves, which enables click tracking.
For example, http%3A%2F%2Fads.example.com%2Fw%2F1.0%2Frc%3Fts%3D555YADAYADA555%26r%3D

Other macros

See additional supported macros. OpenX also supports the following macros, which you can use as needed:

MacroIs replaced with
{random}A random, ten-character, alphanumeric string, which is useful for cachebusting.
For example, QWzLUh1FEK
If you place multiple {random} macros in a creative, each returns a different random value. For example, if your HTML creative contains:
   1. {random}
   2. {random}

Then OpenX replaces each {random} macro with a different random value. For example:
   1. QWzLUh1FEK
   2. qbKM22B57Q
{techno.domain.market}The top-level domain, passed to the OpenX Ad Exchange, where the creative is served.
{techno.page_url_enc.market}The encoded URL, passed to the OpenX Ad Exchange, where the creative is served.
{techno.page_url.market}The URL, passed to OpenX Ad Exchange, where the creative is served.

Price Encrypting Scheme

The price is encrypted using a custom encryption scheme designed to minimize size overhead while ensuring adequate security.

The encryption scheme uses a keyed HMAC-SHA1 algorithm to generate a secret pad based on the unique impression event ID. The encrypted price has a fixed length of 28 bytes. It is comprised of a 16-byte initialization vector, 8 bytes of ciphertext, and a 4-byte integrity signature. The encrypted price is web-safe base-64-encoded with padding characters omitted. Thus, the 28-byte encrypted price is encoded as a 38 character web-safe base 64 string.

The price is encrypted as <price xor HMAC-SHA1(encryption_key, initialization_vector)>.

So the decryption calculates HMAC-SHA1(encryption_key, initialization_vector) and XORs with the encrypted price to reverse the encryption.

The integrity stage takes 4 bytes of <HMAC-SHA1(integrity_key, price||initialization_vector)>, where || is concatenation.

For price decryption, use the code provided at the following GitHub repository.


How to Insert OpenX Macros

You can manually insert OpenX macros into your HTML ads, third-party ads, and click URLs.


Inserting an OpenX macro into a URL

The following example shows how to manually insert a macro into a click-tracking URL:

http://example.com/click?src=ox&pageurl={techno.page_url_enc.market}

In this case, OpenX automatically replaces {techno.page_url_enc.market} with the URL where OpenX serves the creative.


Manually inserting an OpenX macro for cachebusting

Insert a random number into an ad tag 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 inventory, and helps minimize discrepancies between publisher and marketer delivery reports.

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

<img src="http://example.com/img.gif?cb={random}"/>

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


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="http://click_url.com/index.html">
                <img src="http://example.com/img.gif?cb=[replace_with_random_number]"></a>

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="http://example.com/img.gif?cb={random}"></a>

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

<a href="http://ox-d.servedbyopenx.com/ma/1.0/rc?ai=e61725-1767-428e0-9654&ts=1hfeh348efhshdihfhsur">
                <img src="http://example.com/img.gif?cb=QZR9823492"></a>