Swap Paragraphs (p) Phone Numbers with CallTrackerFX

gerard_reyes Posted by: Gerard Reyes Date Posted: August 25, 2026
Back to Case Studies

Issue

The phone number on the site isn’t swapping because it’s in a paragraph tag (<p>).

CallTrackerFX swaps phone numbers that are anchors (<a>).

Solution

I added custom JavaScript code that will swap phone numbers even if they are in a paragraph (<p>) element.

var interval;
var attempts = 0;
function checkAnchors() {
var els = document.querySelectorAll('.location .location__details--center p');
try {
mcfx(function(t) {
for (var i = 0; i < els.length; i++) {
t.modules.calltracking.replaceNumbers(els[i]);
}
});
} catch(err) {
}
attempts++;
if (attempts > 60) {
clearInterval(interval);
}
}
checkAnchors();
interval = setInterval(checkAnchors, 1000);

Achievement

The phone number on the site is successfully swapped by CallTrackerFX.

Snippet/Screenshot/Link

Task: Link

Code: Screenshot