Rezonence

The following presents a guideline on how Rezonence standard and rich media tags should be edited to count clicks in Google Ad Manager. In order to track clicks follow the procedure below:

JavaScript Code

Original Code

You should have received some JavaScript code from Rezonence that looks similar to the following example:

<script type="text/javascript">
(function(trk) {
/*
  Third party tracking URLs can be provided between the quotes of
  the push statements below. Note you will need to uncomment the
  relevant line.

  A pixel tracking url or click tracking macro can be provided, as
  an example, the DFP click tracking macro as already been supplied.
*/

/* Impression tracker */
/* trk.imp.push("[YOUR_IMPRESSION_TRACKER]"); */

/* View tracker */
/* trk.ivw.push("%%VIEW_URL_UNESC%%"); */

/* Engagement tracker */
/* trk.eng.push("%%CLICK_URL_UNESC%%"); */

/* Click tracker */
/* trk.clk.push("[YOUR_CLICK_TRACKER]"); */

/* Video start tracker */
/* trk.vst.push("[YOUR_VIDEO_START_TRACKER]"); */

/* Video 25% completed tracker */
/* trk.v25.push("[YOUR_VIDEO_25PC_TRACKER]"); */

/* Video 50% completed tracker */
/* trk.v50.push("[YOUR_VIDEO_50PC_TRACKER]"); */

/* Video 75% completed tracker */
/* trk.v75.push("[YOUR_VIDEO_75PC_TRACKER]"); */

/* Video ended/completed tracker */
/* trk.ven.push("[YOUR_VIDEO_COMPLETION_TRACKER]"); */

/* Trackers for specific answers, repeat below statement with
   different answer numbers */
/* trk.ans.push({ans:1,trk:""}); */

/* Viewability javascript */
/* trk.vjs.push("[YOUR_VIEWABILITY_JS_TRACKER]"); */

/* Use to override the click through urls for the images */
/* trk.ctu = "[YOUR_CLICK_THROUGH_URL]"; */

var tag = {
    aid: "Advertiser/Name/Test",
    nid: "Rezonence",
    cid: "[CONFIG_ID]",
    did: "[DEAL_ID]",
    lnd: "${CPG_ID}",
    app: false,
    apd: "${EXT_APP_ID}",
    dvd: "${DEVICE_AAID}" + "${DEVICE_APPLE_IDA}" + "${DEVICE_WIN_ID}",
    pld: "[PLACEMENT_ID]",
    vtg: "[VAST_TAG]",
    trk: trk
};
var test=test||!1,tag=tag||{trk:{}};void 0===tag.cap&&(tag.cap=!test),tag.rte=tag.rte||"https://mfk43w9xte.execute-api.eu-west-1.amazonaws.com/production/track",tag.nta=tag.nta||test?"https://r3z-test-eu.S3.amazonaws.com":"https://cdn3.rezonence.com",tag.ntb=tag.ntb||test?"":"https://e43e8e18e725ae6b22e0-f0fde0bbc5469096ab6f7c4eba4934a9.ssl.cf3.rackcdn.com",tag.lda=tag.lda||test?"LdS3.js":"LdCDN3.js",tag.ldb=tag.ldb||test?"":"LdCDN2.js",tag.pxl=tag.pxl||"/Com/SPI.gif";var fld,i,nFlds=["did","pld","lnd"];for(i=0;i<nFlds.length;i++)fld=nFlds[i],tag[fld]=parseInt(tag[fld]);var sFlds=nFlds.concat(["aid","nid","cid","apd","dvd","pld"]);for(i=0;i<sFlds.length;i++)fld=sFlds[i],tag[fld]=sZ(tag[fld]);tag.vtg&&1===tag.vtg.indexOf("VAST_TAG")&&(tag.vtg=void 0);var lo,tm=(new Date).getTime();try{lo=top.location.hostname}catch(t){lo=location.hostname}var sd=tm+"-"+s4()+s4()+s4()+s4(),eU=encodeURIComponent(encodeURIComponent(location.href)),imp={evt:"tagd",aid:tag.aid,nid:tag.nid,did:tag.did,cid:tag.cid,lnd:tag.lnd,pld:tag.pld,pid:lo,apd:tag.apd,adt:"fullflex",cab:tm,sid:sd,url:eU},qp="?"+qS(imp);if(lP(tag.nta+tag.pxl+qp,function(){lP(tag.ntb+tag.pxl+qp)}),lP(tag.rte+qp),!top._r3z||!top._r3z.aid){var _r3z=top._r3z||{};_r3z.aid=tag.aid,_r3z.sid=sd,_r3z.nid=_r3z.nid||tag.nid,_r3z.cid=_r3z.cid||tag.cid,_r3z.APN_LINE_ITEM_ID=tag.lnd,_r3z.did=_r3z.did||tag.did,_r3z.tpm=top.R3Z_TPM||{},_r3z.pld=tag.pld,_r3z.vastTagUrl=tag.vtg,_r3z.app=tag.app?1:0,_r3z.apd=tag.apd,_r3z.dvd=tag.dvd,_r3z.trk=_r3z.trk||{imp:[],ivw:[],ulk:[],eng:[],clk:[],vst:[],v25:[],v50:[],v75:[],ven:[],ans:[],vjs:[]},importTrackers(),!1===tag.cap&&(_r3z.DISABLE_CAPPING=!0),(top._r3z=_r3z).app&&iSE("https://"+lo+"/mraid.js"),iSE(tag.nta+"/Ads/"+_r3z.aid+"/"+tag.lda+"?c="+tm),tag.ntb&&iSE(tag.ntb+"/Ads/"+_r3z.aid+"/"+tag.ldb+"?c="+tm)}function importTrackers(){for(var t in tag.trk)if(tag.trk.hasOwnProperty(t)){var a=tag.trk[t];if(a){if(_r3z.trk[t]=_r3z.trk[t]||[],a.constructor===Array)for(var r=0;r<a.length;r++){var d=a[r];_r3z.trk[t].push(d)}"ctu"===t&&(_r3z.ctu=a)}}}function iSE(t){var a=top.document.head||top.document.getElementsByTagName("head")[0],r=top.document.createElement("script");r.src=t,a.insertBefore(r,a.firstChild)}function sZ(t){if("string"==typeof t)for(var a=["{","}","|","\\","^","~","[","]","`"],r=0;r<a.length;r++){var d=a[r];if(-1<t.indexOf(d))return}else if("number"==typeof t&&isNaN(t))return;return t}function qS(t){var a=[];for(var r in t)if(t.hasOwnProperty(r)){var d=sZ(t[r]);void 0!==d&&a.push(r+"="+d)}return a.join("&")}function lP(t,a){var r=new Image;return r.src=t,a&&(r.onerror=a),r}function s4(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}
})({imp: [], ivw: [], eng: [], clk: [], vst: [], v25: [], v50: [], v75: [], ven: [], ans: [], vjs: [], ctu: ""});
</script>

Modified Code

What you need to do is uncomment the below variables in the <SCRIPT> tag as shown by the highlighted changes, The resulting tag should look similar to the following example:

<script type="text/javascript">
(function(trk) {
/*
  Third party tracking URLs can be provided between the quotes of
  the push statements below. Note you will need to uncomment the
  relevant line.

  A pixel tracking url or click tracking macro can be provided, as
  an example, the DFP click tracking macro as already been supplied.
*/

/* Impression tracker */
trk.imp.push("%%CLICK_URL_ESC%%");

/* View tracker */
/* trk.ivw.push("%%VIEW_URL_UNESC%%"); */

/* Engagement tracker */
/* trk.eng.push("%%CLICK_URL_UNESC%%"); */

/* Click tracker */
trk.clk.push("%%CLICK_URL_ESC%%");

/* Video start tracker */
/* trk.vst.push("[YOUR_VIDEO_START_TRACKER]"); */

/* Video 25% completed tracker */
/* trk.v25.push("[YOUR_VIDEO_25PC_TRACKER]"); */

/* Video 50% completed tracker */
/* trk.v50.push("[YOUR_VIDEO_50PC_TRACKER]"); */

/* Video 75% completed tracker */
/* trk.v75.push("[YOUR_VIDEO_75PC_TRACKER]"); */

/* Video ended/completed tracker */
/* trk.ven.push("[YOUR_VIDEO_COMPLETION_TRACKER]"); */

/* Trackers for specific answers, repeat below statement with
   different answer numbers */
/* trk.ans.push({ans:1,trk:""}); */

/* Viewability javascript */
/* trk.vjs.push("[YOUR_VIEWABILITY_JS_TRACKER]"); */

/* Use to override the click through urls for the images */
/* trk.ctu = "[YOUR_CLICK_THROUGH_URL]"; */

var tag = {
    aid: "Advertiser/Name/Test",
    nid: "Rezonence",
    cid: "[CONFIG_ID]",
    did: "[DEAL_ID]",
    lnd: "${CPG_ID}",
    app: false,
    apd: "${EXT_APP_ID}",
    dvd: "${DEVICE_AAID}" + "${DEVICE_APPLE_IDA}" + "${DEVICE_WIN_ID}",
    pld: "[PLACEMENT_ID]",
    vtg: "[VAST_TAG]",
    trk: trk
};
var test=test||!1,tag=tag||{trk:{}};void 0===tag.cap&&(tag.cap=!test),tag.rte=tag.rte||"https://mfk43w9xte.execute-api.eu-west-1.amazonaws.com/production/track",tag.nta=tag.nta||test?"https://r3z-test-eu.S3.amazonaws.com":"https://cdn3.rezonence.com",tag.ntb=tag.ntb||test?"":"https://e43e8e18e725ae6b22e0-f0fde0bbc5469096ab6f7c4eba4934a9.ssl.cf3.rackcdn.com",tag.lda=tag.lda||test?"LdS3.js":"LdCDN3.js",tag.ldb=tag.ldb||test?"":"LdCDN2.js",tag.pxl=tag.pxl||"/Com/SPI.gif";var fld,i,nFlds=["did","pld","lnd"];for(i=0;i<nFlds.length;i++)fld=nFlds[i],tag[fld]=parseInt(tag[fld]);var sFlds=nFlds.concat(["aid","nid","cid","apd","dvd","pld"]);for(i=0;i<sFlds.length;i++)fld=sFlds[i],tag[fld]=sZ(tag[fld]);tag.vtg&&1===tag.vtg.indexOf("VAST_TAG")&&(tag.vtg=void 0);var lo,tm=(new Date).getTime();try{lo=top.location.hostname}catch(t){lo=location.hostname}var sd=tm+"-"+s4()+s4()+s4()+s4(),eU=encodeURIComponent(encodeURIComponent(location.href)),imp={evt:"tagd",aid:tag.aid,nid:tag.nid,did:tag.did,cid:tag.cid,lnd:tag.lnd,pld:tag.pld,pid:lo,apd:tag.apd,adt:"fullflex",cab:tm,sid:sd,url:eU},qp="?"+qS(imp);if(lP(tag.nta+tag.pxl+qp,function(){lP(tag.ntb+tag.pxl+qp)}),lP(tag.rte+qp),!top._r3z||!top._r3z.aid){var _r3z=top._r3z||{};_r3z.aid=tag.aid,_r3z.sid=sd,_r3z.nid=_r3z.nid||tag.nid,_r3z.cid=_r3z.cid||tag.cid,_r3z.APN_LINE_ITEM_ID=tag.lnd,_r3z.did=_r3z.did||tag.did,_r3z.tpm=top.R3Z_TPM||{},_r3z.pld=tag.pld,_r3z.vastTagUrl=tag.vtg,_r3z.app=tag.app?1:0,_r3z.apd=tag.apd,_r3z.dvd=tag.dvd,_r3z.trk=_r3z.trk||{imp:[],ivw:[],ulk:[],eng:[],clk:[],vst:[],v25:[],v50:[],v75:[],ven:[],ans:[],vjs:[]},importTrackers(),!1===tag.cap&&(_r3z.DISABLE_CAPPING=!0),(top._r3z=_r3z).app&&iSE("https://"+lo+"/mraid.js"),iSE(tag.nta+"/Ads/"+_r3z.aid+"/"+tag.lda+"?c="+tm),tag.ntb&&iSE(tag.ntb+"/Ads/"+_r3z.aid+"/"+tag.ldb+"?c="+tm)}function importTrackers(){for(var t in tag.trk)if(tag.trk.hasOwnProperty(t)){var a=tag.trk[t];if(a){if(_r3z.trk[t]=_r3z.trk[t]||[],a.constructor===Array)for(var r=0;r<a.length;r++){var d=a[r];_r3z.trk[t].push(d)}"ctu"===t&&(_r3z.ctu=a)}}}function iSE(t){var a=top.document.head||top.document.getElementsByTagName("head")[0],r=top.document.createElement("script");r.src=t,a.insertBefore(r,a.firstChild)}function sZ(t){if("string"==typeof t)for(var a=["{","}","|","\\","^","~","[","]","`"],r=0;r<a.length;r++){var d=a[r];if(-1<t.indexOf(d))return}else if("number"==typeof t&&isNaN(t))return;return t}function qS(t){var a=[];for(var r in t)if(t.hasOwnProperty(r)){var d=sZ(t[r]);void 0!==d&&a.push(r+"="+d)}return a.join("&")}function lP(t,a){var r=new Image;return r.src=t,a&&(r.onerror=a),r}function s4(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}
})({imp: [], ivw: [], eng: [], clk: [], vst: [], v25: [], v50: [], v75: [], ven: [], ans: [], vjs: [], ctu: ""});
</script>

Note

The ad server recognises the [timestamp] placeholder and will automatically replace it with a cache buster. It is not necessary to convert it to the %%CACHEBUSTER%% macro manually.

Use %%CLICK_URL_UNESC%% at the beginning of a link. Use %%CLICK_URL_ESC%% when the click-tracker is the parameter of another URL.

<a href="%%CLICK_URL_UNESC%%https://www.google.com">link</a>
<a href="https://www.google.com?rd_url=%%CLICK_URL_ESC%%">link</a>