Version 5.0
AdvertServe User Manual :: v5.0

AdvertPRO Click Tracking

Note Note

Providing these code formats to an advertiser or publisher that will run them through a third-party ad server is not recommended. Instead you should use the third-party code wizard to generate code for them. This specialized code wizard is able to output placeholders for click tracking, random number and timestamp macros so you don't have to enter them manually! In fact, if you know the macros used by their ad server you can enter the real macros instead of using placeholders.

AJAX Code

Original Code

You should have received some AJAX code from AdvertPRO that looks like the following:


<!-- BEGIN ADVERTPRO CODE -->
<script type="text/javascript">
  var _avp = _avp || [];
  (function() {
    var s = document.createElement('script');
    s.type = 'text/javascript'; s.async = true; s.src = 'http://adserver.example.com/js/libcode3.js';
    var x = document.getElementsByTagName('script')[0];
    x.parentNode.insertBefore(s, x);
  })();
</script>
<!-- END ADVERTPRO CODE -->

<!-- BEGIN ADVERTPRO CODE -->
<div id="avp_zid_7">
<script type="text/javascript">
_avp.push({ tagid: 'avp_zid_7', alias: '/', type: 'banner', zid: 7, pid: 0 });
</script>
</div>
<!-- END ADVERTPRO CODE -->

Modified Code

What you need to do is add two variables in the <SCRIPT> code as shown by the highlighted changes:


<!-- BEGIN ADVERTPRO CODE -->
<script type="text/javascript">
  var _avp = _avp || [];
  (function() {
    var s = document.createElement('script');
    s.type = 'text/javascript'; s.async = true; s.src = 'http://adserver.example.com/js/libcode3.js';
    var x = document.getElementsByTagName('script')[0];
    x.parentNode.insertBefore(s, x);
  })();
</script>
<!-- END ADVERTPRO CODE -->

<!-- BEGIN ADVERTPRO CODE -->
<div id="avp_zid_7">
<script type="text/javascript">
_avp.push({ tagid: 'avp_zid_7', alias: '/', type: 'banner', zid: 7, pid: 0, encode: 1, cturl: '%%CLICKLINK%%' });
</script>
</div>
<!-- END ADVERTPRO CODE -->

Note Note

For third party ad servers, you will need to replace %%CLICKLINK%% with their click tracking macro. Be aware that some third party ad servers cannot handle redirects being sent back to them in escaped/encoded form. You can deal with this by changing the value of the encode parameter to zero. It may also be changed to a value greater than one should multiple escaping/encoding passes be required.

HTML Code

Original Code

You should have received some HTML code from AdvertPRO that looks like one of the following following:

JavaScript with built-in cache busting


<!-- BEGIN ADVERTPRO CODE -->
<script type="text/javascript">
document.write('<scr'+'ipt src="http://adserver.example.com/servlet/view/banner/javascript/zone?zid=123&pid=0&random='+Math.floor(89999999*Math.random()+10000000)+'&millis='+new Date().getTime()+'&referrer='+encodeURIComponent((window!=top&&window.location.ancestorOrigins)?window.location.ancestorOrigins[window.location.ancestorOrigins.length-1]:document.location)+'" type="text/javascript"></scr'+'ipt>');
</script>
<!-- END ADVERTPRO CODE -->

JavaScript with click tracking and random number placeholder


<!-- BEGIN ADVERTPRO CODE -->
<script type="text/javascript" src="http://adserver.example.com/servlet/view/banner/javascript/zone?zid=123&pid=0&random=[random]&encode=1&cturl=[clickurl]" type="text/javascript"></script>
<!-- END ADVERTPRO CODE -->

IFRAME with click tracking and random number placeholder


<!-- BEGIN ADVERTPRO CODE -->
<iframe src="http://adserver.example.com/servlet/view/banner/javascript/html/zone?zid=123&pid=0&random=[random]&encode=1&cturl=[clickurl]" height="60" width="468" hspace="0" vspace="0" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
<!-- END ADVERTPRO CODE -->

Modified Code

What you need to do is modify the URL in the <SCRIPT> or <IFRAME> tags as shown by the highlighted changes:

JavaScript with built-in cache busting


<!-- BEGIN ADVERTPRO CODE -->
<script type="text/javascript">
document.write('<scr'+'ipt src="http://adserver.example.com/servlet/view/banner/javascript/zone?zid=123&pid=0&random='+Math.floor(89999999*Math.random()+10000000)+'&millis='+new Date().getTime()+'&encode=1&referrer='+encodeURIComponent((window!=top&&window.location.ancestorOrigins)?window.location.ancestorOrigins[window.location.ancestorOrigins.length-1]:document.location)+'&cturl=%%CLICKTAG%%" type="text/javascript"></scr'+'ipt>');
</script>
<!-- END ADVERTPRO CODE -->

JavaScript with click tracking and random number placeholder


<!-- BEGIN ADVERTPRO CODE -->
<script type="text/javascript" src="http://adserver.example.com/servlet/view/banner/javascript/zone?zid=123&pid=0&random=%%RANDOM%%&encode=1&cturl=%%CLICKTAG%%" type="text/javascript"></script>
<!-- END ADVERTPRO CODE -->

IFRAME with click tracking and random number placeholder


<!-- BEGIN ADVERTPRO CODE -->
<iframe src="http://adserver.example.com/servlet/view/banner/javascript/html/zone?zid=123&pid=0&random=%%RANDOM%%&encode=1&cturl=%%CLICKTAG%%" height="60" width="468" hspace="0" vspace="0" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
<!-- END ADVERTPRO CODE -->

Warning Warning

It is extremely important that the cturl parameter be added to the end of the URLs in every <SCRIPT> and <IFRAME> tag. AdvertPRO may misinterpret your click tracking URL if it is not the last parameter. This is due to the fact that AdvertPRO uses methods not standard to the HTTP URL specification to parse parameters in an effort to be compatible with third party ad servers that do not properly URL encode their tracking URLs. Additionally, if you must also specify referrer or redirect parameters in the URLs, they must be in this order: referrer, cturl, redirect at the end of the URLs.

Note Note

For third party ad servers, you will need to replace %%CLICKTAG%% and %%RANDOM%% with their own specific click tracking and random number macros. Be aware that some third party ad servers cannot handle redirects being sent back to them in escaped/encoded form. You can deal with this by changing the value of the encode parameter to zero. It may also be changed to a value greater than one should multiple escaping/encoding passes be required.

JavaScript Code

Original Code

You should have received some JavaScript code from AdvertPRO that looks like the following:


<!-- BEGIN ADVERTPRO CODE -->
<script src="http://adserver.example.com/js/libcode1_noajax.js" type="text/javascript"></script>
<!-- END ADVERTPRO CODE -->

<!-- BEGIN ADVERTPRO CODE -->
<script type="text/javascript">
if (document.avp_ready) { avp_zone({ base: 'adserver.example.com', type: 'banner', zid: 7, pid: 0 }); }
</script>
<!-- END ADVERTPRO CODE -->

Modified Code

What you need to do is modify the URL in the <A> tag as shown by the highlighted changes:


<!-- BEGIN ADVERTPRO CODE -->
<script src="http://adserver.example.com/js/libcode1_noajax.js" type="text/javascript"></script>
<!-- END ADVERTPRO CODE -->

<!-- BEGIN ADVERTPRO CODE -->
<script type="text/javascript">
if (document.avp_ready) { avp_zone({ base: 'adserver.example.com', type: 'banner', zid: 7, pid: 0, encode: 1, cturl: '%%CLICKLINK%%' }); }
</script>
<!-- END ADVERTPRO CODE -->

Note Note

For third party ad servers, you will need to replace %%CLICKLINK%% with their click tracking macro. Be aware that some third party ad servers cannot handle redirects being sent back to them in escaped/encoded form. You can deal with this by changing the value of the encode parameter to zero. It may also be changed to a value greater than one should multiple escaping/encoding passes be required.