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']);
_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.
No comments:
Post a Comment