Tacking using JavaScript

In most cases, using a standard tracking pixel to track your campaign will work just fine. However, sometimes a tag manager requires you to insert a javascript instead of just an image tag or a URL.

If this is the case, you can use the following template: 

<script>
(function(tcode, e){
    var img = new Image();
    img.src = 'https://visitanalytics.userreport.com/hit.gif?t=' + encodeURIComponent(tcode) + '&event=' + encodeURIComponent(e || 'impression') + '&rnd=' + (new Date()).getTime();
    }('TCODE'));
</script>

Here you simply need to swap out "TCODE" with your actual t-code that you can extract from your tracking pixel. 

<img src="https://visitanalytics.userreport.com/hit.gif?t=XXX12345678">

In this case, you take your t-code,  XXX12345678, and paste it into the formula which will then look like this: 

<script>
(function(tcode, e){
    var img = new Image();
    img.src = 'https://visitanalytics.userreport.com/hit.gif?t=' + encodeURIComponent(tcode) + '&event=' + encodeURIComponent(e || 'impression') + '&rnd=' + (new Date()).getTime();
    }('XXX12345678'));
</script>

If you want to use another type of event pixel, you will need to use the below format:

<script> 
(function(tcode, e){
var img = new Image();
img.src = 'https://visitanalytics.userreport.com/hit.gif?t=' + encodeURIComponent(tcode) + '&event=' + encodeURIComponent(e || 'impression') + '&rnd=' + (new Date()).getTime();
}('TCODE','EVENT'));
</script>

Here you can switch out EVENT with the event type like i.e. "conversion". However, when doing this, please keep in mind that the script in itself will track whatever it is implemented to track. This means that simply using the conversion script will not nessisairily track conversions. It will need to be implemented on the part of the site which will reflect just this, or in a specific event type container depending on the event that you are looking to track. 

Please feel free to contact us at support@audiencereport.com if you have any further questions.

 

Attachments

Comments

Powered by Zendesk