Created
February 8, 2026 12:36
-
-
Save vanaf1979/fabac9ff72bc189e3ab7526199998e71 to your computer and use it in GitHub Desktop.
GA4 email phone clicks
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
| // Track Telephone Clicks | |
| const phoneLinks = document.querySelectorAll('a[href^="tel:"]'); | |
| phoneLinks.forEach(link => { | |
| link.addEventListener('click', () => { | |
| gtag('event', 'contact_click', { | |
| 'type': 'phone', | |
| 'number': link.href | |
| }); | |
| }, { once: true }); | |
| }); | |
| // Track Email Clicks | |
| const emailLinks = document.querySelectorAll('a[href^="mailto:"]'); | |
| emailLinks.forEach(link => { | |
| link.addEventListener('click', () => { | |
| gtag('event', 'contact_click', { | |
| 'type': 'email', | |
| 'address': link.href | |
| }); | |
| }, { once: true }); | |
| }); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment