Skip to content

Instantly share code, notes, and snippets.

@amberhinds
Created January 8, 2019 22:15
Show Gist options
  • Save amberhinds/4c3145e3b82b053b247175bea205ffc0 to your computer and use it in GitHub Desktop.
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
<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>
@amberhinds
Copy link
Author

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