Skip to content

Instantly share code, notes, and snippets.

@johnnyopao
Last active December 15, 2022 11:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save johnnyopao/a47f8e13f542655ec1f7 to your computer and use it in GitHub Desktop.
Save johnnyopao/a47f8e13f542655ec1f7 to your computer and use it in GitHub Desktop.
Unbounce - Adwords Call tracking - Consolidated (text/links/buttons) - See full instructions here: http://documentation.unbounce.com/hc/en-us/articles/203509834
<script>
// NOTE: If you want to track these links as conversion goals on Unbounce,
// change 'clkn' to 'clkg' in the commented areas below
// Add the button ID's to this array that you want tracked
// For example: ['#lp-pom-button-12', '#lp-pom-button-20']
var callButtons = [];
var ubCallback = function(formatted_number, unformatted_number) {
var numberLinks = document.getElementsByClassName('number_link');
var numberTexts = document.getElementsByClassName('number_text');
// Clickable text number Links
$(numberLinks).each(function(i, numberLink) {
// Change clkn to clkg if you are tracking your links as Unbounce conversion goals
numberLink.href = "clkn/tel/" + unformatted_number;
numberLink.innerHTML = "";
numberLink.appendChild(document.createTextNode(formatted_number));
});
// Non-clickable text
$(numberTexts).each(function(i, numberText) {
numberText.innerHTML = "";
numberText.appendChild(document.createTextNode(formatted_number));
});
// Button numbers
$(callButtons).each(function(i, callButton) {
// Change clkn to clkg if you are tracking your links as Unbounce conversion goals
$(callButton).attr("href", "clkn/tel/" + unformatted_number);
$(callButton + " span").text(formatted_number);
});
};
</script>
<script>
$(function(){
_googWcmGet(ubCallback, '1-800-123-4567')
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment