Created
July 20, 2026 22:53
-
-
Save undfine/9ec0b9185a28c4a0f9c993d5e184eae3 to your computer and use it in GitHub Desktop.
google ads call tracking script
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
| var gtagPhoneCallback = function(display_number, linked_number) { | |
| // Replace the number as needed. | |
| var targetLinks = document.querySelectorAll('a[href^="tel:+11231231234"]'); | |
| // Swap only the exact matching elements found | |
| for (var i = 0; i < targetLinks.length; i++) { | |
| targetedLinks[i].href = "tel:" + linked_number; | |
| targetedLinks[i].innerText = display_number; | |
| } | |
| }; | |
| // 2. Initialize the Google Ads configuration | |
| gtag('config', 'AW-CONVERSION_ID/CONVERSION_LABEL', { | |
| 'phone_conversion_number': '123.123.1234', | |
| 'phone_conversion_callback': gtagPhoneCallback | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment