The example below is applicable to a website with one number group. 

The tracking script will replace the main number that is prominently displayed in the header, and then find all other occurrences of the main number (that might exist in text, footers, etc), with the dynamic number.

In this example the main number that will be replaced is 1300 012 345, the phone number in the header is wrapped in an element with ID header-phone, and the name of the number group is main.phoneNumber.

While the call to replaceById is not required, it improves the speed of number switching to the extent where the user often cannot notice number switching occurring at all, which works to improve the user experience.


<script type="text/javascript">
var _ctq = _ctq || [];
_ctq.push(['setSiteId', 'FD-01234567']);
_ctq.push(['requires', ['main.phoneNumber']]);
_ctq.push(['replaceById', 'header-phone', 'main.phoneNumber', '#### ### ###']);
_ctq.push(['replaceText', /1300\s?012\s?345/g, 'main.phoneNumber', '#### ### ###']);
_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>


Break down of the tracking part of the script.

<script type="type=text/javascript"> - the opening of the script.


var_ctq = _ctq || [ ]; - the setting of variables.


_ctq.push (['setSiteId', 'FD-01234567']); - this is the line that links the script to the Site/Project of the tracking service provided by Fone Dynamics .


_ctq.push (['requires', ['main.phoneNumber']]); - this line calls the dynamic number pool/s to be used for call tracking.


_ctq.push (['replaceById', 'header-phone', 'main.phoneNumber', 'n']); - this line is optional, it searches the webpage for text wrapped by the ID "header-phone".


_ctq.push (['replaceText', /1300\s?012\s?345/g, 'main.phoneNumber', 'n']); - this line is mandatory, it will search the webpage for the number to replace, the formatting of the number is crucial. 


_ctq.push (['trackPageView']); - this line initiates the call tracking for the current page view and fetch any requested dynamic numbers.  Note this method must be called last.


(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> - the closing of the script. 




We also have a dynamic tracking script that is tailored to track Google Adwords only.


This version of the tracking script is only triggered only when the websites URL includes "/gclid=/g"


A Cookie "VA__ADWORDS" is created on the viewers browser.


<script type="text/javascript">
  // Dynamic Tracking code BLANK.com.au - XX-XX-XXXX
(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-XXXXXXXXX']);
  _ctq.push(['requires', ['main.phoneNumber']]);
  _ctq.push(['replaceText', /\(?03\)?\s?8592\s?4608/g, 'main.phoneNumber', {format:'n'}]);
  _ctq.push(['onNumberAvailable', function(num) { if (jQuery) jQuery("a[href$='(03)%208592%204608']").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>


Otherwise this script is the same as the default all traffic script.