Track tel: and mailto: click with Google Analytics and jQuery
jQuery(document).ready(function(){
//set up the vars
var eCat = 'contact',
eAct = '',
eLabel = window.location.pathname;
//target href attributes that begin tel:
jQuery(document).on('click','[href^="tel:"]', function(e) {
//set the action as tel
eAct = 'tel:'+ jQuery(this).attr('href');
//track event
ga('send', 'event', eCat, eAct, eLabel );
});
//target href attributes that begin mailto:
jQuery(document).on('click','[href^="mailto:"]', function(e) {
//set the action as email
eAct = 'email:' + jQuery(this).attr('href');
//track event
ga('send', 'event', eCat, eAct, eLabel );
});
});