Sign in

Welcome.
How can we help?

Can I replace a phone number on click?

Topic: , Updated:

The script has the functionality to request a trackable phone number upon any external event, for example a click on a button, via the built in function getNumber.

In this example the script will not try to automatically find and replace phone number(s) on a website, but instead request a trackable phone number initiated by an onClick event.

<html>
<
script type="text/javascript"> var __fs_conf = __fs_conf || []; __fs_conf.push(['setAdv',{'id': 'advid'}]); __fs_conf.push(['numberDetection', false]); </script> <script type="text/javascript" src="//analytics.freespee.com/js/external/fs.js"></script>
<p>Number is: <span id="nr" onClick="doOnClick();">Click here to see phone number</span></p> <script> function doOnClick() { var a = document.getElementById('nr'); __fs_dncs_instance.getNumber( function(ref,res) { ref.innerHTML=res.local; }, a, '+44201234567', 'advid' ); } </script>
</html>

Important: Please make sure to add the "__fs_conf.push(['numberDetection', false]);" config to your script configuration.

Was this article helpful?
1 out of 2 found this helpful

Comments

  • Avatar
    JC Mengant
    I think the doOnClick function should be : function doOnClick() { var a = document.getElementById('nr'); __fs_dncs_instance.getNumber( function(ref,res) { ref.innerHTML=res.local; }, a, '+44201234567', 'advid' ); }
  • Avatar
    Tobias Lindgren
    Hi! Thanks for helping out, you're right there was a small typo in the example, I've updated it now. Cheers, /Tobias

Not the answer to your question?

Powered by Zendesk