1. Knowledge Base
  2. Search & Replace Script

Do a lot of pools or content harm my website performance?

I do have many pools on my site or a lot of content on my site, does this harm the script performance?

If you have a website with a lot of pools/search texts (>400) and/or with much content (DOM Elements) our script will need more computing cycles to complete the search & replace. In some cases this can lead to unwanted behavior. 

To get ahead of this issue you can use the "getNumberBySearchtext" method within the matelso script. Using this method you can fetch a call-tracking number by it's search text from a script within the page. After fetching the number the user script has to place the number within the DOM. Using this method we can skip the search within the website content, which can increase the performance.

How to use the "getNumberBySearchtext" method?

To use the method "getNumberBySearchtext" you first need to add the matelso script to your website. After that you need to define a callback method in your user-script. This callback method takes two parameters (numberObject & errorString) and will be invoked by the matelso script after fetching the call-tracking number. If there was an error fetching the number, the callback will be called with an errorString.

The numberObject contains the number formatted as e164, tel-link and also in the format configured in the control panel.

Following is an example of the callback method:

var callback = function(numberObject, errorString){
    if(!numberObject){
        console.log('getNumberBySearchtext failed:', errorString);
        return;
    }
    // Do something with the number here
}

Missing within this example is the logic to place the number within the DOM. This needs to be implemented by the website administrator.

After fulfilling those requirements you can call the method using the following example snippet:

window[window.CallTrackingObject]("getNumberBySearchtext", "{SEARCHTEXT}", callback);

Within this example you can see {SEARCHTEXT} as a placeholder for the search text you want to use to fetch the call-tracking number.