Click Tracking for 3rd-Party Ads


If an Advertiser provides a 3rd Party Ad, you can edit the Creative properties to dynamically create click URLs that include tracking codes for both Kevel and 3rd-Parties, such as DoubleClick, Atlas, Sizmek, etc.

This lets your Advertisers use their own services/servers for validating clicks.

3rd-Party Tracking Basics

A typical ad tag from a 3rd-party provides an image source URL and a click destination URL:

<a href="http://advertiser_click_url"><img src="http://advertiser_image_url" /></a>

While not all tags are built this way, all click tags will have a "click URL" that works the same way.

To incorporate this into a Creative, the basic steps are:

  1. Take the destination URL from the click URL and use that as the Creative's Click URL
  2. Enable the Creative to be 'JavaScript/HTML' format
  3. Use the same tracking tag from the 3rd-party, but replace the click URL with this macro: {{URL}}

See the instructions below for handling codes from various well-known trackers.

In the UI, you can also use the "Convert to Kevel Macros" button in a creative to automatically add tracking macros to tags supported in this article. (Currently, Doubleclick, Sizmek, Atlas and Flashtalking tags are supported).



For a <noscript> section, you'll need to instead keep the click URL in the creative's code and insert {{url}}&url= before it, like: <a href="{{url}}&url=http://advertiser_click_url">

{{URL}} Macro

The {{url}} macro generates an Kevel tracking URL and replaces the third party's destination URL.

If you append our click tracking URL as a parameter in the creative, use the macro {{url|url_encode}} instead. This will urlencode the click tracking URL when the creative is rendered.

For more information on macros, see Macros/Tokens.



If your creative requires multiple destination URLs, use macros {{urls[1]}}, {{urls[2]}}, and so forth. These will load links in the order that you enter URLs in the clickURL box.

Adding 3rd-Party Tracking - API

To dynamically add click tracking tags to a creative, you'll want to use the Create Creative endpoint.

These are the field you have to edit to enable:

Set to true
Fill with a HTML/JavaScript ad. See below for examples of what various tracker codes look like.
URLThe click URL. If the 3rd party is tracking clicks, it should have the service's domain in it. If the service is only doing impression tracking, it's the standard landing page

See the examples on this page about what the different tags look like, based on company.

For instance, here's an example of a JSON request to create a creative that includes a DFA-click-tracking-URL:

  "Title":"Adzerk Blue Creative",
  "ScriptBody": "<SCRIPT language=\"JavaScript1.1\" SRC=\";sz=728x90;click={{url|add(\"&url=\")}};ord={{timestamp}}?\"> </SCRIPT>",



Make sure to add \ before quotation marks within the ScriptBody string to prevent it from breaking.

Adding 3rd-Party Tracking - UI

  1. When Setting up a Creative, select "JavaScript/HTML" as the Format.
  2. Add in the code snippets shown below.
  3. Add in the Click URL where you want the ad to be directed.
  4. Save.

Appending URL to Click URL

Some third-party tags require that you append another URL to the end of the click tracking URL that is generated by the click tracking macro.

For example, when these tags are written to a page, they may write the click URL of the creative as a series of redirects: First the tracking URL from the third-party platform, then a redirect to Kevel's click tracking URL, and then another redirect to the advertiser's original click URL.

If this is the case, add the parameter &url= to the end of the click macro, so it becomes {{url}}&url=https://advertiser_click_url, etc. This will enable Kevel's click tracking URL to redirect to another URL after a user clicks on an ad.

For example:

<a href="{{url}}&url=https://advertiser_click_url">



The example code snippets provided below are for demonstration purpose only. You will need to modify whatever code is provided by the Advertiser accordingly.


Currently, Kevel cannot track clicks for AdSense creatives because their system is not compatible with our macros.


<SCRIPT SRC="{{timestamp}}&referrer={{request.url.href}}&pubclick={{url|url_encode}}%26url= " TYPE="text/javascript"></SCRIPT> 
<!-- END TAG -->


Atlas tags should use the click={{url|add("&url=%u")}} macro instead of {{url}}:

<script language="JavaScript" type="text/javascript" src="{{timestamp}}?click={{url|add("&url=%u")}}"> 

An alternate form of Atlas tags will use `{{url|url_encode}}%26url=:``

<script src=";p=1234567890;cache=?click={{url|url_encode}}%26url="><iframe src=";p=1234567890;cache=?click={{url|url_encode}}" width="728" height="90" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>


<script type='text/javascript'>
document.MAX_ct0 ='{{url|url_encode}}%26url=';
var m3_u = (location.protocol=='https:'?'':'');
var m3_r = Math.floor(Math.random()*99999999999);
document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
document.write ("zoneid=123456");document.write("&amp;nodis=1");
document.write ('&amp;cb=' + m3_r);
if (document.MAX_used != ',') document.write ("&amp;exclude=" + document.MAX_used);
document.write (document.charset ? '&amp;charset='+document.charset : (document.characterSet ? '&amp;charset='+document.characterSet : ''));
document.write ("&amp;loc=" + escape(window.location));
if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer));
if (document.context) document.write ("&context=" + escape(document.context));
if ((typeof(document.MAX_ct0) != 'undefined') && (document.MAX_ct0.substring(0,4) == 'http')) {
document.write ("&amp;ct0=" + escape(document.MAX_ct0));
if (document.mmm_fo) document.write ("&amp;mmm_fo=1");
document.write ("'></scr"+"ipt>");

Doubleclick for Advertisers (DFA)

If the advertiser is using DoubleClick and Javascript, the code will look something like this:

<SCRIPT language="JavaScript1.1" SRC=";sz=728x90;ord=[timestamp]?"> </SCRIPT>

To enable click-tracking on these creatives within Kevel:

  1. Modify the URL by replacing [timestamp] with {{timestamp}}
  2. Add click={{url|add("&url=")}} before ord=


<SCRIPT language='JavaScript1.1' SRC=";sz=728x90;click={{url|add("&url=")}};ord={{timestamp}}?"> </SCRIPT>



Below works slightly differently than other examples. Here, you will need to change the Click URL field in the Creative, as well as the "JavaScript/HTML" section.

If the advertiser is using Doubleclick with an image tag, the code will look something like this:

<A HREF=";sz=728x90;ord=[timestamp]" target="_blank">

<IMG SRC=";sz=728x90;ord=[timestamp]?"BORDER=0 WIDTH=728 HEIGHT=90 ALT="Advertisement"></A>

To enable click-tracking on these creatives within Kevel:

  1. Modify the URL by replacing [timestamp] with {{timestamp}}.
  2. Copy the URL in the tag, remove the question mark at end (if present), and paste in the Click URL field of the Creative.
  3. Cut out the URL from the tag code and replace with {{url}}.


<A HREF="{{url}}" target="_blank">

<IMG SRC=";sz=728x90;ord={{timestamp}}?" BORDER=0 WIDTH=728 HEIGHT=90 ALT="Advertisement"></A>;sz=728x90;ord={{timestamp}}

Doubleclick Campaign Manager Ad Tag

<ins class='dcmads' style='display:inline-block;width:300px;height:250px'
<script src='//'></script>


<script language="Javascript1.1" type="text/javascript">
var ftClick = "{{url|url_encode}}%26url=";
var ftExpTrack_1258613 = "";
var ftX = "";
var ftY = "";
var ftZ = "";
var ftOBA = 1;
var ftContent = "";
var ftCustom = "";
var ft728x90_OOBclickTrack = "";
var ftRandom = Math.random()*1000000;
var ftBuildTag1 = "<scr";
var ftBuildTag2 = "</";
var ftClick_1155613 = ftClick;
if(typeof(ft_referrer)=="undefined"){var ft_referrer=(function(){var r="";if(window==top){r=window.location.href;}else{try{r=window.parent.location.href;}catch(e){}r=(r)?r:document.referrer;}while(encodeURIComponent(r).length>1000){r=r.substring(0,r.length-1);}return r;}());}
var ftDomain = (window==top)?"":(function(){var d=document.referrer,h=(d)?d.match("(?::q/q/)+([qw-]+(q.[qw-]+)+)(q/)?".replace(/q/g,decodeURIComponent("%"+"5C")))[1]:"";return (h&&h!"&ft_ifb=1&ft_domain="+encodeURIComponent(h):"";}());
var ftTag = ftBuildTag1 + 'ipt language="javascript1.1" type="text/javascript" ';
ftTag += 'src=";1175613;291;js;YourSiteName;728x90Leader/?ftx='+ftX+'&fty='+ftY+'&ftadz='+ftZ+'&ftscw='+ftContent+'&ft_custom='+ftCustom+'&ftOBA='+ftOBA+ftDomain+'&ft_referrer='+encodeURIComponent(ft_referrer)+'&cachebuster='+ftRandom+'" id="ftscript_728x90" name="ftscript_728x90"';
ftTag += '>' + ftBuildTag2 + 'script>';

Sizmek / MediaMind

<script src="{{timestamp}}&ucm=true&ncu={{url|url_encode}}&click=$$"></script> 
<a href="" target="_blank"><img src="" border=0 width=160 height=600></a></noscript>


MediaPlex creatives need to be encoded and redirected to the destination URL.

<!-- JavaScript Only --> 
<script type="text/javascript" src="{{timestamp}}&mpvc={{url|url_encode}}%26url="> 
<a href="{{timestamp}}"> 
<img src="{{timestamp}}" 
alt="Click Here" border="0"> 

Open Ad Server (OAS) / 24/7 / RealMedia

script language="JavaScript"> 
var RN = new String (Math.random()); 
var RNS = RN.substring (2,11); 
var oas_jx_sitepage = "Etihad_Apr2013_Set_2_FSA" ; 
var oas_jx_pos = "Middle3"; 
var publisher_click = "{{url|add("&url=%u")}}"; 
document.write("<scr" + "ipt language=\"JavaScript\" src=\"" + oas_jx_sitepage + "/1" + RNS + "@" + oas_jx_pos + "?" + publisher_click + "\"></scr" + "ipt>"); // --> 


If you are using OpenX ad code, it should include a placeholder where you can insert the {{URL}} macro. If it does not, you will want to manually add the following line of code after the first line.

document.MAX_ct0 ={{url}};

Here is an example:

<script type='text/javascript'><!--//<![cdata[ 
document.MAX_ct0={{url}}var m3_u = (location.protocol=='https:'?''');


<!-- Javascript tag -->

<!-- begin ZEDO for channel: Adzerk Display , publisher: Adzerk , Ad Dimension: Medium Rectangle - 300 x 250 -->

<script language="JavaScript">

var zflag_nid="1111"; var zflag_cid="3333/3334"; var zflag_sid="19238"; var zflag_width="300"; var zflag_height="250"; var zflag_sz="2"; var zflag_click="{{url}}&url=";


<script language="JavaScript" src=""></script>

None of the Above

If your code follows some other format, please check with the network or advertiser that sent you the code to learn how it accepts a click tracking macro. If you follow their instructions and clicks are still not tracking, please contact our support team.