Skip to content

Instantly share code, notes, and snippets.

@taf2
Created April 2, 2014 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taf2/9935072 to your computer and use it in GitHub Desktop.
Save taf2/9935072 to your computer and use it in GitHub Desktop.
number replacement with custom formatting examples
// insert code here: https://calltrackingmetrics.com/accounts/tracking_script_settings
window.CTMSourceEvent = function(event) {
if(event.state=='after') {
// generic solution to replace a number format for a given element after our code runs e.g. after event.
document.getElementById("the-phone").innerHTML = "Insert Your Custom Number Format";
}
if (event.state == 'node:after') {
// more fine grained control of replacement you have access to the exact DOM Element we've located a number and replaced.
if (event.node.innerHTML.match(/Your number digits to match/)) {
event.node.innerHTML = event.node.innerHTML.replace(/replace our formatting/,"with your formatting");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment