Advanced science. Smarter decisions. Superior monetization.

Magic Macros

Magic Macros are macro commands you can place in the banner HTML (or destination URL) for an ad to insert various attributes into the generated ad code.

Content

Magic Macro Description
{clickurl} The OpenX click tracking URL for the delivered ad

e.g. http://.../delivery/ck.php?oaparams=2__bannerid=...

{clickurl_enc} The encoded OpenX click tracking URL for the delivered ad

e.g.

http%3A%2F%2F...%2Fdelivery%2F...

 

{timestamp} A decimal string based on the current timestamp (in seconds and microseconds since the UNIX epoch

e.g. 1185290310.72

{random} A 10 character alpha-numeric random string value

e.g. b616f31e72

{logurl}* The OpenX impression logging URL

e.g. http://.../delivery/lg.php?bannerid=...

{logurl_enc}* As {logurl} but the logging URL is urlencoded

e.g. http%3A%2F%2F...%2Fdelivery%2Flg.php%3Fbannerid%3D...

{target} The target value for the selected banner

e.g. _blank

{url_prefix} The URI to the base of the OpenX delivery server

e.g. http://ads.example.com/www/delivery

{bannerid} The ID of the selected banner

e.g. 123

{zoneid} The ID of the selected zone

e.g. 456

{source} The value of "source=" as passed into the ad-request from the site tags

e.g. source=cat123/cat456...

{pageurl} The URL of the page the ad was requested on (url encoded)

e.g. http%3A%2F%2Flocalhost%2Fmagic_macros%2Ftest.html

{referer} The referer of the page the ad was requested on (url encoded)

e.g. http%3A%2F%2Flocalhost%2Fmagic_macros%2F

{width} The width (in pixels) of the selected ad

e.g. 468

{height} The height (in pixels) of the selected ad

e.g. 60

{clickurlparams} The parameters which would be passed to the {clickurl}

e.g. 2__bannerid=X__zoneid=Y__source=cat123/cat456__cb=0d9139d879__maxdest=

{ANY_INPUT_VARIABLE} Any value present in the php $_REQUEST array ($_GET/$_POST/$_COOKIE)

e.g. {OAID} -> $_COOKIE['OAID'] = 1fd819ffc7267757ba681ff5daa3007e

If any of the magic macros are present in the HTML, but the value cannot be found, then the replaced value depends on the type of macro:

  • For core macros ending in id - The value zero is used
  • For other core macros - An empty string is used
  • For "ANY_INPUT_VARIABLE" macros - The macro string is left unchanged in the HTML

*NOTE: If either {logurl} or {logurl_enc} are detected in an HTML ad, OpenX will not log an impression, but will pass the logging URL on to a 3rd party and rely on them to call-back using the logurl provided.

URL Macros

The {clickurl} Macro

By inserting the {clickurl} macro into the banner HTML for an ad stored on a third party server, OpenX can track clicks on that ad.

More information: The ThirdPartyClickTracking white paper describes how to implement this feature.

When the ad is clicked, OpenX substitutes the click tracking URL for the macro, for example http://.../delivery/ck.php?oaparams=2__bannerid=.... The browser is redirected to this URL where OpenX counts the click and then forwards the browser to the ad URL.

{clickurlparams}

The {clickurlparams} are the parameters that are passed to the {clickurl} address for third party click tracking. The parameters are:

  • bannerid
  • zoneid
  • source
  • cb
  • maxdest

{pageurl}

The URL of the page that requested the ad (url-encoded), for example http%3A%2F%2Flocalhost%2Fmagic_macros%2Ftest.html

{logurl}

To track impressions for third party ads, use the {logurl} macro. When the ad is displayed, OpenX substitutes the impression logging URL for the macro, for example http://.../delivery/lg.php?bannerid=.... The browser is redirected to this URL where OpenX logs the impression and then forwards the browser to the ad. As with the {clickurl} macro, OpenX appends various parameters for the ad to the URL and passes these to the impression logging page.

{logurl_enc}

The {logurl_enc} macro is similar to the {logurl} macro but the substituted URL is url-encoded, for example http%3A%2F%2F...%2Fdelivery%2Flg.php%3Fbannerid%3D....

{url_prefix}

The URL to the base of the OpenX delivery server, for example http://ads.example.com/www/delivery