Skip to content

Instantly share code, notes, and snippets.

@amberhinds
Created January 8, 2019 22:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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>
@AlexShim777
Copy link

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?

@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