CallTrackerFX was not tracking before my fix. The issue has something to do with the Text and HREF not matching. For example, the text is “(888) 366-7624,” but the href is “8883667624.” CallTrackerFX is looking for a href equal to “(888) 366-7624” but cannot find it. It is worth noting, CTFX should be able to swap this under normal circumstance but for some reason, it does not work on this site.
Create a custom code to swap the number using a special selector from text to match the href.
<script>
(function() {
var runs = 25;
var fxINT = setInterval(function() {
runs--;
if (runs == 0) {
console.log('clearing');
clearInterval(fxINT);
}
if (CallTrack.numbersToReplace) {
CallTrack.numbersToReplace.forEach(function(item) {
if (item.number.length) {
// The number changes before this is executed so add the changed number in the array too.
item.number.push(item.replace);
// Makes the array unique
item.number = item.number.filter(function(value, index, self) {
return self.indexOf(value) === index;
});
item.number.forEach(function(thenums) {
var replace = thenums.replace(/\D/g, ''); // Enable the regex for this ticket.
replace = replace.trim(); // Trim because sometimes there are trailing spaces in the number.
document.querySelectorAll('a[href*="' + replace + '"]').forEach(function(thenum) {
thenum.href = 'tel:' + item.tel;
});
document.querySelectorAll('a.wixui-rich-text__text').forEach(function(thenum) {
if (thenum.textContent.includes(thenums)) {
thenum.textContent = item.replace;
}
});
var anchorElements = document.querySelectorAll('a[href^="tel:"]');
anchorElements.forEach(function(anchor) {
var spanElements = anchor.querySelectorAll('span');
spanElements.forEach(function(spanElement) {
if (spanElement.textContent.trim() === thenums) {
spanElement.textContent = item.replace;
}
});
});
});
}
});
}
}, 500);
})()
</script>
CallTrackerFX can swap the phone numbers.