Tracking Script Template

Modified on Tue, 6 Feb, 2024 at 3:16 PM

<script type="text/javascript">
var _ctq = _ctq || [];
_ctq.push(['setSiteId', Site ID]);
_ctq.push(['requires', [Group 1, Group 2, ..]]);
// Insert calls to replacement methods here
_ctq.push(['trackPageView']);

(function() {
var wca = document.createElement('script'); wca.type = 'text/javascript'; wca.async = !0;
wca.src = "//web-call-analytics.com/wca.js";
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(wca, s);
})();
</script>

Calls to replacement methods (described in the Methods section) must be inserted into this tracking script to enable number switching.


Sample Script to measure All Traffic:


<script type="text/javascript">

  // Dynamic Tracking code https://testsample.com - 26-01-2024

  var _ctq = _ctq || [];

  _ctq.push(['setSiteId', 'VA-00000000']);

  _ctq.push(['requires', ['main.phoneNumber']]);

  _ctq.push(['replaceText', /\S?00\s?0000\s?0000/g, 'main.phoneNumber', {format:'n'}]);

  _ctq.push(['onNumberAvailable', function(num) { if (jQuery) jQuery("a[href$='0000000000']").attr('href', 'tel:' + num); }, 'main.phoneNumber', {format:'n'}]);

  _ctq.push(['trackPageView']);

  

  (function() {

    var wca = document.createElement('script'); wca.type = 'text/javascript'; wca.async = !0;

    wca.src = "https://web-call-analytics.com/wca.js";

    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(wca, s);

  })();

}

</script>



Adwords Only Tracking Script


This script is for tracking Google Adwords traffic to a website. I.e. this script will only fire if the visitor comes to the website via a Google Adwords Link.


The script detects if the URL includes a ‘Google Click ID' - “gclid” ’ and creates a Cookie in the browser. If the cookie is present then the ‘Swapping’ part of the script will fire.


Example Tracking Script:




<script type="text/javascript">

  // Dynamic Tracking code https://www.example.com.au/ - 26-01-2024

(function(f,e,g){function h(b,d){var a=new Date;a.setTime(a.getTime()+864E5*d);document.cookie=b+"=1; "+("expires="+a.toUTCString())+"; path=/"}null!==window.location.href.match(f)&&h(e,g);window[e]="1"===function(b){b+="=";for(var d=document.cookie.split(";"),a=0;a<d.length;a++){for(var c=d[a];" "==c.charAt(0);)c=c.substring(1);if(0==c.indexOf(b))return c.substring(b.length,c.length)}return""}(e)})(

    /gclid=/g,

    "VA__ADWORDS",

    30

);

if (window['VA__ADWORDS'] === true) {

  var _ctq = _ctq || [];

  _ctq.push(['setSiteId', 'VA-00000000']);

  _ctq.push(['requires', ['main.phoneNumber']]);

  _ctq.push(['replaceText', /\S?00\s?00000\s?00000/g, 'main.phoneNumber', {format:'n'}]);

  _ctq.push(['onNumberAvailable', function(num) { if (jQuery) jQuery("a[href$='0000000000']").attr('href', 'tel:' + num); }, 'main.phoneNumber', {format:'n'}]);

  _ctq.push(['trackPageView']);

  

  (function() {

    var wca = document.createElement('script'); wca.type = 'text/javascript'; wca.async = !0;

    wca.src = "//web-call-analytics.com/wca.js";

    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(wca, s);

  })();

}

</script>


UTM Tracking Script


<script type="text/javascript">

  // Dynamic Tracking code https://www.example.com.au/ - 26-01-2024

(function(f,e,g){function h(b,d){var a=new Date;a.setTime(a.getTime()+864E5*d);document.cookie=b+"=1; "+("expires="+a.toUTCString())+"; path=/"}null!==window.location.href.match(f)&&h(e,g);window[e]="1"===function(b){b+="=";for(var d=document.cookie.split(";"),a=0;a<d.length;a++){for(var c=d[a];" "==c.charAt(0);)c=c.substring(1);if(0==c.indexOf(b))return c.substring(b.length,c.length)}return""}(e)})(

    /gclid=|utm_source=google&utm_medium=cpc/g,

    "VA__UTMtags",

    30


);

if (window['VA__UTMtags'] === true) {

  var _ctq = _ctq || [];

  _ctq.push(['setSiteId', 'VA-00000000']);

  _ctq.push(['requires', ['main.phoneNumber']]);

  _ctq.push(['replaceText', /\S?00\s?00000\s?00000/g, 'main.phoneNumber', {format:'n'}]);

  _ctq.push(['onNumberAvailable', function(num) { if (jQuery) jQuery("a[href$='0000000000 ']").attr('href', 'tel:' + num); }, 'main.phoneNumber', {format:'n'}]);

  _ctq.push(['trackPageView']);

  

  (function() {

    var wca = document.createElement('script'); wca.type = 'text/javascript'; wca.async = !0;

    wca.src = "https://protect-au.mimecast.com/s/OhZeCANpRAunmNzUO1dMH";

    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(wca, s);

  })();

}

</script>


Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article