matelso logo 2022 brand
matelso logo 2022 brand
View Categories

How can I retrieve a call tracking number in a single page application?

Due to the dynamic nature of single-page applications, a normal “search & replace” approach is not sufficient. In this case there are two ways to implement it.

 

Manual scan #

The first and easiest way is to use the “scan” method of the Matelso script. This will trigger a new scan of the website for search text. This method is called manual scan. In this case, a script call is still set to an event or like page_view or in case of reloaded content.

/code
MANUAL SCAN:
// Test if the tracking library is already loaded
if (mtls.loaded) {
// run the website scan
mtls.scan();
}
/code

More information about manual scan: manual scan

 

“getNumberBySearchtext” method #

This method allows you to retrieve a call tracking number based on its search text from a Matelso script on the page. After retrieving the number, a custom script from you/the user must place the number in the DOM. This method can be used to skip the search in the website content, so there are no problems with a single page application.

 

How to use the method “getNumberBySearchtext”? #

We recommend that this method is set up by a person with appropriate knowledge of websites and scripts.

To use the “getNumberBySearchtext” method, the Matelso script must be implemented on the page and a callback method must also be defined. This callback method is called by the Matelso script as soon as the call tracking number is available. If an error occurs while requesting the call tracking number, the error message is passed to the callback method.

More information on how to set up this method can be found here:
getNumberbySearchtext