Adding click tracking / clicktags to iframes / HTML-ads in Adtech / Helios

After producing an HTML5 banner, living in an iframe, delivered through Adtech / Helios, we had a case where the clicks weren’t tracked by the advertising platform. That’s as expected, since the content hosting the iframe is unable to manipulate any content within the iframe (unless they’re on the same originating host, and we’re serving our content by ourselves to make it dynamic and without a huge setup cost (in time)).

Turns out Adtech / Helios has a few variables that it can replace when delivering the URL or the HTML of the iframe (similar to the function of a clickTAG for Flash content):

_ADCLICK_: Standard variable for click tracking
_ADCLICKESC_: URL is escaped by the ad server
_ADCLICKDEC_: Decoded target URL
_ADCLICKDECESC_: Decoded and escaped URL

We went with _ADCLICK_, which will be replaced by the URL to prefix any link in your own content with. That way the click will be routed through the tracking code at the ad server, and the counts should match what we’re actually seeing on the other side (through analytics and events).

Luckily the link to prefix does not contain any special characters that need to be escaped (they use ; as a separator) when used in as GET arguments in an URL, so you can add an argument to the existing URL:

http://www.example.com/?ad=1&clicktrack=_ADCLICK_
<iframe src="http://www.example.com/?ad=1&clicktrack=_ADCLICK_"></iframe>

You can then pick this up in your server side language and prefix all urls, or you can extract it in JavaScript and add it to any link available in dynamic content.

This also works in data- attributes for the iframe, allowing you to retrieve the click prefix through javascript from that parameter as well.