setSiteId

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

Method
String
Yes
The method to be executed. Must be 'setSiteId'.
Site ID
String
Yes
The Site ID (also known as the tracking code) that corresponds to the tracking service.

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

Method
String
Yes
The method to be executed. Must be 'requires'.
Number Groups
String[]
Yes
An array of number group names to request from the tracker. By default, the main number group is named '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

Method
String
Yes
The method to be executed. Must be '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

Method
String
Yes
The method to be executed. Must be 'replaceText'.
Find
Regex
Yes
A regular expression describing the text the find.
Number Group
String
Yes
The corresponding number group. A dynamic number from this number group will be used to replace any matches. This number group must be specified in the initial call to requires.
Number Format
String?
No
The formatting to use for the replacement phone number. The # character specifies a number. Other characters are left unchanged. Useful examples include '#### ### ###' 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

Method
String
Yes
The method to be executed. Must be 'replaceById'.
ID
String
Yes
The ID of the element that should have its contents replaced with the dynamic number.
Number Group
String
Yes
The corresponding number group. A dynamic number from this number group will be used to replace any matches. This number group must be specified in the initial call to requires.
Number Format
String?
No
The formatting to use for the replacement phone number. The # character specifies a number. Other characters are left unchanged. Useful examples include '#### ### ###' 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

Method
String
Yes
The method to be executed. Must be 'replaceByClassName'.
Class Name
String
Yes
The class name of the element(s) which should have their contents replaced with the dynamic number.
Number Group
String
Yes
The corresponding number group. A dynamic number from this number group will be used to replace any matches. This number group must be specified in the initial call to requires.
Number Format
String?
No
The formatting to use for the replacement phone number. The # character specifies a number. Other characters are left unchanged. Useful examples include '#### ### ###' 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

Method
String
Yes
The method to be executed. Must be 'onNumberAvailable'.
Function
Function(String)
Yes
The function to call with the dynamic number. The tracking script will provide the formatted dynamic number as the first argument to the function.
Number Group
String
Yes
The corresponding number group. A dynamic number from this number group will be used to replace any matches. This number group must be specified in the initial call to requires.
Number Format
String?
No
The formatting to use for the replacement phone number. The # character specifies a number. Other characters are left unchanged. Useful examples include '#### ### ###' 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']);