Event Tracking - Google Analytics (ga.js)

Posted by Pandiyarajan on June 16, 2009 · Filed Under Google, Google Analytics 

Possible Events:

In any interactive environment, the program should be able to respond to actions performed by the user. These action can be mouse click, key press or selection of a menu item. What are the possible events we can track using ga.js as follows

  • If you have anchor tag for third party site link which you want to track how many clicks from our site.

  • If you have mailto: on anchor tag and you want to track how many of them click for mail link.

  • In your home page you might have request for quote image, follow us on twitter image etc.. where you want to track, how many clicks on the image.

  • If you have a button for email subscription button, newsletter subscription etc… Where you want to track the clicks.

  • When you want to track while you submit action in the form tag

Event Handlers usage in website:

We found out what are the possible events available in the website now we will see, the possible methods available in the website are

  • onClick: whenever the mouse click event available we can use onclick method in the website.
    if you take 2
    nd possible event as we discussed already. < a href=mailto: test@seoservicegroup.com onclick=javascript: method()>seoservicegroupmail</a>.
    Note: xhtml = use onclick html4.0 <= use onClick

  • onSubmit: Whenever you submit form property, onsubmit event method occurs. If you take 4th possible event as per our discussion earlier. <form action=”somemethodcall()” onsubmit=javascript: mehodcall()>……<input type=”submit” name=”submit” value=”submit”></form>
    Note: xhtml= use onsubmit html4.0<= use onSubmit

For more event handlers refer http://w3schools.com/jsref/jsref_events.asp

Event Tracking method ga.js:

We can track the events what we discussed so far, ga.js provide us the event tracking method called _trackEvent(). _trackEvent() method first create and send event tracking call to google analytics tracking code. For example we consider the first event handlers as per our discussion

Syntax:

_trackEvent(category, action, opt_label, opt_value)

Note: Caegory and action are mandatory parameters in trackevent method

<a href=mailto: test@seoservicegroup.com onclick=javascript: pageTracker._trackEvent(“mail”, “click”, “Request through mail”)>seoservicegroupmail</a>.

We added pageTracker object which we created for google analytics through ga.js, Using pageTracker we call the method viz _trackEvent(). This method will send the event once the person click on seoservicegroupmail. Inside the method we pass parameters like mail, click and request through mail which are category, action and label respectively. For more customization details on ga.js Contact Us

Disclaimer: The post is completely based on individual thoughts and SEO Services Group bears no responsibilities for the thoughts reflected in the post.

Popularity: 35% [?]

[Post to Twitter] Tweet This Post 

Related Posts

Comments

7 Responses to “Event Tracking - Google Analytics (ga.js)”

  1. tabsfiroz on June 16th, 2009 5:48 am

    Hi Pandiya,

    Great explanation of page tracking using trackevent, but i have a few queries

    1. If I am correct, the trckevent method doesnt create false page views as created by the trackpageview method right? I read about it in the Google webmaster forums so just wanted to confirm…

    2. And for tracking form submits, I have a ‘thnkyou’ page displayed after the submit function, so at this point do i use the trckevent method or the trackpageview method? or use both, as i need to view how many page views are present for my ‘thankyou’ page assuming you only reach that page when you submit the form.

  2. Raghavan on June 16th, 2009 7:00 am

    @tabsfiroz - You can directly find the pageviews for the “Thankyou” in Analytics from Top Exit pages in the Content section.

  3. pandiya on June 16th, 2009 2:35 pm

    @tabsfiroz- Actually your confusing trackevent with pageview, If you have a request for a quote button you want to know how many of them click request for quote button but not send the enquiry. You can track the click using event and goals using pageview.

  4. Jack Bond on June 17th, 2009 8:40 am

    Hi
    Great explanation of page tracking using track event
    you write great example of Event Handlers usage in website and Event Tracking method ga.js but you explain next blog are more depth
    Thanks for writting

  5. PlugIM.com on June 18th, 2009 4:26 am

    Event Tracking Using Google Analytics (ga.js)…

    In any interactive environment, the program should be able to respond to actions performed by the user. These action can be mouse click, key press or selection of a menu item. What are the possible events we can track using ga.js as follows

    *

  6. How I Make $300 a Day Online on June 18th, 2009 11:01 am

    Hey, great post, really well written. You should write more about this.

  7. Richard on September 16th, 2009 3:09 am

    Hi ,i’m looking for tutorial on google analytics on ajax form submission.

    I don’t get any solution to my problem and still i’m looking for help.
    Could you please solve my this problem.

    I have a Ajax contact us form which i implement with my homepage+ajaxform.html file.So when user click on homepage+ajaxform.html page , the Ajax form
    appears with other content of homepage+ajaxform.html page. My ajax contact form don’t have any other thank you page or successfully
    submission page which can appear after submitting form.

    A thank you message appears within my same Ajax contact page.

    So i want when user open my homepage+ajaxform.html page and click send message button after filling my contact form my google analytics
    works and i get information about that form submission in my google analytics account.

    here is the links of my form…………..

    (plz copy and paste this link to address bar)

    http://www.lucknowchicken.com/Ajax-Form/homepage+ajaxform.html

    you can download my Ajax form files by clicking on this link

    plz copy and paste this link to address bar)

    http://www.lucknowchicken.com/Ajax-Form/Download.rar

    Please try to solve my problem…Thanks

Leave a Reply