Created
January 8, 2019 22:15
-
-
Save amberhinds/4c3145e3b82b053b247175bea205ffc0 to your computer and use it in GitHub Desktop.
Track tel: & mailto: link clicks as goals in Google Analytics - passes events to corresponding Analytics goals
This file contains 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 type='text/javascript'> | |
jQuery(function($){ | |
// mailto function | |
$('a[href^="mailto:"]').click(function(){ | |
ga('send','event','mailto','click','email clicked'); | |
return true; | |
}); | |
}); | |
jQuery(function($){ | |
// tel function | |
$('a[href^="tel:"]').click(function(){ | |
ga('send','event','tel','click','phone clicked'); | |
return true; | |
}); | |
}); | |
</script> |
Hi, it's possible that something has changed in Google Analytics since this was set up. You might want to try switching to a Google Analytics 4 property for easier configuration of event tracking. Unfortunately, I cannot provide free support on this at this time.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello.
I added this code to the site header and imported the goal settings from the gallery.
Nothing works yet.
Perhaps I missed something? Is there anything else you need to do?