Created
November 27, 2023 15:19
-
-
Save jamesmills/a065be63417310245a5ffe95ba394919 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
AnyTrack(function() { | |
// generates the user client id | |
var at_click_id = AnyTrack('atclid'); | |
var campaign = new Retreaver.Campaign({ | |
campaign_key: '{{ $campaign['retreaverCampaignKey'] }}' | |
}); | |
var tags = { | |
sub_id: at_click_id | |
}; | |
campaign.request_number(tags, function(number) { | |
let phoneLinks = document.querySelectorAll('.phone-link, .phone-link-text'); | |
phoneLinks.forEach(phoneLink => { | |
phoneLink.href = 'tel:' + number.get('number'); | |
// Update text only for elements with 'phone-link-text' class | |
if (phoneLink.classList.contains('phone-link-text')) { | |
phoneLink.textContent = number.get('formatted_number'); | |
} | |
}); | |
window.addEventListener('beforeunload', function(e) { | |
if (number && typeof number.release === 'function') { | |
number.release(); | |
} | |
}); | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment