You are here: Demand Partners > Real-time bidding APIs > Macros

Macros for Demand Partners

Last updated on July 14, 2017

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. 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:


This topic describes supported macros with sample replacement values, price encrypting, and explains how to insert macros.

Supported macros

The following section outlines the two types of macros that are supported for OpenRTB buyers and OpenX proprietary API buyers) and which macros are supported for each.

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 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 repository:

How to insert OpenX Macros

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

Feedback form