I’ve been looking for ways to track phone calls using Google Analytics but always I find some third party add-on to track which obviously aren’t free.
Luckily I got the code below that you need to put before closing </head> tag in your header.php file, if you are using WordPress.
If you are not using WordPress, then use the following code in the header or footer of the website.
Below is the code for tracking the phone calls using Google Analytics
<script><!-- if (typeof jQuery != 'undefined') { jQuery(document).ready(function($) { jQuery('a').on('click', function(event) { var href = jQuery(this).attr('href'); if (href.substr(0,4) == 'tel:') { var phoneNum = href.substr(4); var elEv = []; elEv.value=0, elEv.non_i=false; elEv.category = "mobile call"; elEv.action = "call"; elEv.label = phoneNum; elEv.non_i = true; elEv.loc = href; if(window._gat){ //Classic _gaq.push(['_trackEvent', elEv.category, elEv.action, elEv.label, elEv.value, elEv.non_i]); }else{ //Universal ga('send','event', elEv.category,elEv.action,elEv.label,elEv.value); } setTimeout(function() {window.location.href = elEv.loc;}, 400); if ( window.console && window.console.log ) {console.log ( 'Called: ' + elEv.label);} return false; } }); }); } --></script>
It would take 24 hours for those call record be shown in the Analytics.
You will see the stats under Behaviour > Events > Overview section.
One most important thing: This will only track those phone numbers that you have given them the link as tel:
Example: tel:0410123123
Let me know how this tracking goes for you.
Wow! It’s the great idea of provide the code for tracking the phone calls using Google Analytics. It’s really appreciable that you have shared such a great kind of post on internet.