28
May 2010
How to track clicks on Internal Links and Submit Button using Event Tracking in Google Analytics
Posted By - Mark Spenser

Recently one of our clients wanted to track how often visitors click on internal links and submit button on his website. After looking at client’s requirement, without delay solution tinted in my mind and that was Event Tracking in Google Analytics.

After implementing event tracking code in client’s website, we were able to see data in Google Analytics within an hour.

After achieving desired results, I thought I should share my experience at here.

I’ll guide you here step by step about how to track visitor’s behavior on your website using event tracking in Google Analytics.

Step 1: Installing Google Analytics Code directly after <body> tag

You need to create a profile in Google Analytics to get Google Analytics tracking code if you don’t have already Google Analytics code within your website.

You have to to put Google Analytics code directly after the opening of body tag (<body>) so the JavaScript required for event tracking is already loaded.

You need to make sure about your Google Analytics code should have below lines. (If your website is running with urchin (old) Google Analytics code then you need to replace it with advanced code which you can get from your existing website profile in Google Analytics.)

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'XX-XXXXXXXX-X']); (Account number will be unique)
 _gaq.push(['_trackPageview']);

Step 2: Implementing Event tracking code to track click on particular internal link

Below is the code to track how often visitors click on particular internal link:

<a href="http://www.example.com" onClick="_gaq.push(['_trackEvent', 'Category', 'Action']);">Example</a>

  • Category (Required)

The name you provide for the group of objects you want to track.

  • Action (required) 

A string that is uniquely paired with each category, and commonly used to define the type of user interaction for the web object.


Step 3: Implementing Event tracking code to track click on submit button of contact forms

Below is the code to track how often visitors click on submit button of contact form on your particular web page. (How many visitors fill up the contact form on your particular web page.)

onSubmit="_gaq.push(['_trackEvent', 'Contact Form', 'Submit']);"

You can change the text “Contact Form” as per your need. Rest of the code must be the same.

That’s it.

Google says that if event tracking code is installed in a right way then you’ll be able to see the Data in Google Analytics after 24 to 48 hours. (May be within an hour.)

You can view the data in Google Analytics under Event Tracking section located under Content Menu.

Below I’ve placed the screenshot for the same.

Event Tracking in Google Analytics

It’s advisable to implement above event tracking code with the help of your programmer IF adding/editing code is not your cup of coffee.

Hope this article will help you out whenever you’re looking for Event Tracking solution in Google Analytics, but in the meantime if you find any query during implementing event tracking code in Google analytics then don’t hesitate to post your query by posting comment, I would be glad to respond you.

Thank You!!

Blog Category 

Search Engine Optimization




All articles posted in this blog are copyright of PLAVEB Corporation. It is strictly prohibited to
republish it without backlink to our respective website pages or without prior permission.
© 2012 PLAVEB Corporation – Web Design Company. All Rights Reserved.