You are here: Blog » Code Snippets » Google Analytics Track Phone Number Clicks

Google Analytics Track Phone Number Clicks

This is a snippet you can use in Google Analytics to track phone number clicks. The code looks slightly different depending on if you use analytics.js or the older ga.js tracking code.

Note that I prefer to use the click event handler as opposed to inline onclicks. This makes for cleaner code and also it’s much easier than having to remember to add the onclick every single time you use a telephone link.

The reason that I start with a preventDefault() is that in my testing, I found that the ga(‘send’…) line wasn’t pushing the event trigger to google analytics. Thus, I first send the message to google analytics, then manually trigger the phone number dialing action.

If you use analytics.js

If you use ga.js

 

Hope it comes in handy. Would be happy to hear from you.

 

This entry was posted in Code Snippets and tagged , , by .

Author: justin saad

Justin Saad is first and foremost a husband and a father of four. He is also a web developer and designer who has been making websites for over fifteen years. His company is called The Motech Network and his website is ClevelandWebDeveloper.com. In addition to building websites, Justin makes WordPress plugins and likes writing tutorials to help others learn about various aspects of web development.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">