Description
Sets the Site ID of the current site to the Site ID of the tracking service provided by Fone Dynamics. This method must be called before any other method.
Syntax
_ctq.push(['setSiteId', Site ID]);
Parameters
'setSiteId'
.Example
_ctq.push(['setSiteId', 'FD-02345678']);
requires
Description
Indicates the required number groups to the tracking script. This enables the tracking script to request these number groups on its initial contact with the Fone Dynamics tracker.
Syntax
_ctq.push(['requires', [Group 1, Group 2, ..]]);
Parameters
'requires'
.'main.phoneNumber'
.Example
_ctq.push(['requires', 'main.phoneNumber']);
trackPageView
Description
Instructs the tracking script to communicate to the tracking service to track the current page view and fetch any requested dynamic numbers.
Notes
This method must be called last.
Syntax
_ctq.push(['trackPageView']);
Parameters
'trackPageView'
.Example
_ctq.push(['trackPageView']);
replaceText
Description
Instructs the tracking script to search for all occurrences of the specified phone number(s), and replace the matches with the specified dynamic number.
Notes
This method waits for the DOM to be ready before executing. As a result, it may be possible for the user to see the number switch while the website loads.
Syntax
_ctq.push(['replaceText', Find, Number Group, Number Format]);
Parameters
'replaceText'
.requires
.'#### ### ###'
and '(##) #### ####'
.Examples
Basic Replacement by Text
The below example finds all occurrences of 1300 012 012 and replaces it with a dynamic number from the main.phoneNumber number group. The replacement will work even if the spacing is missing between digits.
_ctq.push(['replaceText', /1300\s?012\s?012/g, 'main.phoneNumber', '#### ### ###']);
Replacement of Phone Word and/or Digit Version
The below example finds all occurrences of 1800 366 322 and 1800 FONECALL and replaces it with a dynamic number from the main.phoneNumber number group. The replacement will work even if the spacing is missing between digits.
_ctq.push(['replaceText', /1800\s?(366\s?322|FONECALL)/g, 'main.phoneNumber', '#### ### ###']);
replaceById
Description
Instructs the tracking script to replace the contents of the element with the specified ID with the specified dynamic number.
Notes
This method can perform the replacement before the DOM is ready. This is useful as it prevents the user from seeing the number switch in most cases. It is recommended to use this function as the first replacement call to replace the most prominent number on the website (usually in the header).
Syntax
_ctq.push(['replaceById', ID, Number Group, Number Format]);
Parameters
'replaceById'
.requires
.'#### ### ###'
and '(##) #### ####'
.Example
Replacement by ID
The below example replaces the contents of an element with ID header-phone with a dynamic number from the main.phoneNumber number group.
_ctq.push(['replaceById', 'header-phone', 'main.phoneNumber', '#### ### ###']);
replaceByClassName
Description
Instructs the tracking script to replace the contents of all elements with a matching class name with the specified dynamic number.
Notes
This method waits for the DOM to be ready before executing. As a result, it may be possible for the user to see the number switch while the website loads.
Syntax
_ctq.push(['replaceByClassName', Class Name, Number Group, Number Format]);
Parameters
'replaceByClassName'
.requires
.'#### ### ###'
and '(##) #### ####'
.Example
Replacement by Class Name
The below example replaces the contents of all elements with the class name dynamic-phone with a dynamic number from the main.phoneNumber number group.
_ctq.push(['replaceByClassName', 'dynamic-phone', 'main.phoneNumber', '#### ### ###']);
onNumberAvailable
Description
Instructs the tracking script to call the specified function when it becomes aware of the dynamic number.
Notes
In some circumstances it is possible for the tracking script to call the specified function twice with different dynamic numbers. This can occur when the tracking script has a cached dynamic number and then receives an update from the tracking server with a different dynamic number, usually due to session inactivity where the cached dynamic number has been recycled. In this scenario, the initial call will be with the cached dynamic number (used to speed up the number switching on-site), and the second call will be with the updated dynamic number. The last call should be considered the correct dynamic number.
Syntax
_ctq.push(['onNumberAvailable', Function, Number Group, Number Format]);
Parameters
'onNumberAvailable'
.requires
.'#### ### ###'
and '(##) #### ####'
.Examples
Popup of Dynamic Number
The below example displays a popup with a dynamic number from the main.phoneNumber number group.
var popupFunc = function(num) { alert('The dynamic number is ' + num + '.'); }; _ctq.push(['onNumberAvailable', popupFunc, 'main.phoneNumber', '#### ### ###']);
jQuery Replacement of Elements with Dynamic Number
The below example uses jQuery to replace the phone number in links (such as tel: links) that end with 1300012345 with a telephone link pointing to the dynamic number from the main.phoneNumber number group.
var telReplaceFunc = function(num) { $("a[href$='1300012345']").attr('href', 'tel:' + num); } _ctq.push(['onNumberAvailable', telReplaceFunc, 'main.phoneNumber']);