Truemag

  • Categories
    • Tips And Tricks
    • Internet
    • PHP
    • Javascript
    • CSharp
    • SQL Server
    • Linux
  • Lastest Videos
  • Our Demos
  • About
  • Contact
  • Home
  • Write With Us
  • Job Request
Home Tips And Tricks How To Tracking Click Event With Google Analytics

How To Tracking Click Event With Google Analytics

As you know, Google Analytics is the most popular website analytics which let you see and analyze your website traffic include Visitors, Traffic Sources, PageViews, etc. In addition, it also allows you to set up Event Tracking. For example, you want to track how many time your download button/link is clicked or your play button is pressed or even track how many percent a particular video is played by with a call out function from your player script.

Before we continue, please make sure you placed Google Tracking Code on somewhere your website (before the </body> tag). To track a particular event, you can use either of following methods:

To make it simple, I will create a click with an event tracking when click on that link.

1. Event Tracking with _trackEvent

<a href="javascript:void(0);" onClick="_gaq.push(['_trackEvent', 'Downloads', 'Click', 'Test Download Tracking']);">Click here to raise a track</a>

The html code will render something like this:

Click here to raise a track

Assume that you’re browsing the page on Firefox with Firebug plugin installed. When click on the link above, the onClick event will call the _gaq.push function to track.

Firebug Google Analytics _trackEvent

Firebug Google Analytics _trackEvent

How the report looks like, let’s open the Google Analytics, from your Website Dashboard page, click on Content tab on the left then click on Event Tracking tab.

Google Analytics Event Tracking

Google Analytics Event Tracking

As you see on the image above, all event tracking is counted. That’s awesome.

Read more: go to Event Tracking Guide on Google

2. Page Tracking with _trackPageview

<a href="javascript:void(0);" onClick="_gaq.push(['_trackPageview', 'download_source_code']);">Click here to download the source code</a>

The html code will render something like this:

Click here to download the source code

When click on the link above, it will track and count for download_source_code as a page content. Let’s check how Firebug displays:

Firebug Google Analytics _trackPageView

Firebug Google Analytics _trackPageView

To see how many time the download_source_code was “viewed”, open the Google Analytics then go to Content => Top Content => type the tracking named ‘download_source_code‘ on the Filter Page text box => Go

Google Analytics Top Content

Google Analytics Top Content

Feel free to let us know how you go with it.

Apr 20, 2011 Hoan Huynh
Export/Import Data From Local Database To Remote Database With MS SQL Server 2008How To Hide Affiliate And External Links On Wordpress Blog
You Might Also Like:
  • How To Track Website With Multiple Google Analytisc Accounts
  • How To Add User To Your Google Analytics Report
  • How To Export Google Analytics Report To PDF Or XML
  • Export Google Analytics Report To PDF In New Version
  • How To Send Google Analytics Report To Emails
  • Monitor Real Time Visitors, Viewing Pages And Traffic Sources In Google Analytics
  • PHP Google Analytics API Examples
  • PHP open source google analytics competitor
  • Install Firebug On Google Chrome
  • The date of 4rapiddev launching
  • http://www.in.uk.com/society/military/ uk web directory

    Hello my friend! I wish to say that this article is awesome, great written and include almost all vital infos. I’d like to peer extra posts like this .

  • Netz

    Hi!

    Great read – But i have a question. Why are you using a java around the code?
    On Google’s guide it only the code… What is the function of the java (to stop the page for reload?) Yours article is far better than google guide. You have real examples of code where Google don’t … Hope you can clarify this for me?

  • Flavio

    Sometimes the _utm.gif? relative to the element doesn’t appear on firebug, it’s normal?

    Great article! Thanks.

Hoan Huynh

Hoan Huynh is the founder and head of 4rapiddev.com. Reach him at hoan@4rapiddev.com

7 years ago Tips And Tricks_trackEvent, _trackPageview, Firebug, Firefox, Google Analytics, onClick139
0
GooglePlus
0
Facebook
0
Twitter
0
Digg
0
Delicious
0
Stumbleupon
0
Linkedin
0
Pinterest
Most Viewed
PHP Download Image Or File From URL
14,301 views
Notepad Plus Plus Compare Plugin
How To Install Compare Text Plugin In Notepad Plus Plus
10,259 views
Microsoft SQL Server 2008 Attach Remove Log
Delete, Shrink, Eliminate Transaction Log .LDF File
10,259 views
JQuery Allow only numeric characters or only alphabet characters in textbox
8,977 views
Firefox Can Not Connect To Proxy Server
Fix Can Not Connect To Proxy Server In Firefox, Google Chrome And Internet Explorer
5,869 views
4 Rapid Development is a central page that is targeted at newbie and professional programmers, database administrators, system admin, web masters and bloggers.
Recent Posts
  • Magento Fatal error: Unsupported operand types
  • Ionic bower the name contains uppercase letters
  • PHP Magento Get Manufacturer Name And ID From Magento Product ID
  • Know Simple Hacks To Systematize Media Library in WordPress
  • A handy guideline on adding custom menu item in WordPress admin
Categories
  • CSharp (45)
  • Facebook Graph API (19)
  • Google API (7)
  • Internet (87)
  • iPhone XCode (8)
  • Javascript (35)
  • Linux (26)
  • MySQL (16)
  • PHP (84)
  • Problem Issue Error (29)
  • Resources (32)
  • SQL Server (25)
  • Timeline (5)
  • Tips And Tricks (140)
EMAIL SUBSCRIPTION

Sign up for our newsletter to receive the latest news and event postings.

Recommended
  • CDN
  • Hosting
  • Premium Themes
  • VPS
2014 © 4 Rapid Development