|Help Centre

How can I add an event listener?

Last updated at

You may register event listeners in order to execute code when the Freespee script successfully replaces numbers on the page. Each listener will be executed once for each successful number replacement. See example below.

var listener = function(element, number, replacedWith) {
  console.log(number + " was replaced with " + replacedWith + " in element " + element.id);
  //tell user about the number replacement
__fs_conf.push(['setAdv',{'id': 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'}]);
__fs_conf.push(['addNumberReplacedListener', listener]);

Can't find what you're looking for?