Description
Tag initialization
Both JavaScript files need to be initialised in the head in order to detect adblocks.
1 2 3 4 5 6 7 8 9 10 |
<head> <script src="./js/smarttag.js"></script> <script src="./js/adblock/blockadblock.js"></script> </head> //Footer //At Internet tracker initialization var tag = new ATInternet.Tracker.Tag(); |
Adblock detection implementation
Once the adblock is detected from BlockAdBlock.js you can use one of the following functions to send the information to AT internet Interface.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
//Function from the "blockadblock.js" library function adBlockDetected() { //Method 2.1 - Publisher impression function AtInternet_Adblock_hit(); //or Method 2.2 and 2.3 - Click or Custom variable AtInternet_Adblock_hit("detected"); } function adBlockNotDetected() { //Method 2.2 and 2.3 - Click or Custom variable AtInternet_Adblock_hit("not_detected"); } if(typeof blockAdBlock === 'undefined') { adBlockDetected(); }else{ blockAdBlock.onDetected(adBlockDetected).onNotDetected(adBlockNotDetected); } |
Publisher implementation
1 2 3 4 5 6 7 8 9 10 11 |
function AtInternet_Adblock_hit() { tag.publisher.send({ impression:{ campaignId : '[adblock]', creation : '[detection]', url : '[/tests/detection-adblock.html]' } }); } |
Click implementation
1 2 3 4 5 6 7 8 9 10 11 12 13 |
function AtInternet_Adblock_hit(value) { return tag.click.send({ elem:element, // DOM element given name:'adblock', chapter1:'adblock', chapter2:"'" + value + "'", //value = "detected" or "not_detected" level2:'1', //Your level 2 click type:'action', }); } |
Custom variables imlementation
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
function AtInternet_Adblock_hit(value) { hit.customVars.set({ site: { 1: value, } }); //Page hit hit.page.set({ chapter1:'plugin', chapter2:'clic', name: 'detection-adblock.html', level2:'3' }); //To send the page hit hit.dispatch(); } |
Reviews
There are no reviews yet.