Last active
February 17, 2018 15:08
-
-
Save EastSideCode/a59971aaddc73ebcdf3bb8f40b67cc75 to your computer and use it in GitHub Desktop.
Add phone call tracking for Google Analytics
This file contains hidden or 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
| // 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