Skip to content

Instantly share code, notes, and snippets.

@EastSideCode
Last active February 17, 2018 15:08
Show Gist options
  • Select an option

  • Save EastSideCode/a59971aaddc73ebcdf3bb8f40b67cc75 to your computer and use it in GitHub Desktop.

Select an option

Save EastSideCode/a59971aaddc73ebcdf3bb8f40b67cc75 to your computer and use it in GitHub Desktop.
Add phone call tracking for Google Analytics
// add tracking for phone call clicks
function google_phone_clicks() { ?>
<!-- phone call tracking for analytics -->
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery("a[href^='tel:']").click(function(event){
if (typeof __gaTracker !== 'undefined') {
__gaTracker('send', 'event', 'Contact', 'Phone', 'Click');
}
});
});
</script>
<?php
}
// include in footer
add_action('wp_footer', 'google_phone_clicks');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment