Event Tracking Google & Universal Analytics – Complete Guide

 

This post is a guide on ‘event tracking’ feature in Google Analytics and it explains ‘Event Tracking and Virtual PageViews from A to Z in an easy to understand language.  So here we go.

The Basics

Virtual Pageviews

  1. Generating virtual pageviews
  2. Naming Conventions for Virtual Pageviews
  3. Best practices for creating virtual pageviews
  4. Setting up virtual pageviews as goal
  5. Tracking Virtual Pageviews in Universal Analytics

 

Event Tracking

  1. Setting up Event Tracking in Google Analytics
  2. Setting up Event Tracking in Universal Analytics
  3. Advantage of using Event Tracking over Virtual pageviews
  4. Best practices for setting up event tracking
  5. Event Tracking Reports
  6. Automating and Scaling Event Tracking

 

The Basics

The first thing that you need to understand is the meaning of ‘event’ from Google Analytics perspective.

Event is a user’s interaction /activity with a webpage element like flash videos, gadgets, images, links etc.

An event can be:

Downloading a file
Loading of Ajax, JavaScript or flash contents
Loading of a dynamically generated webpage
Loading of pop-ups, light boxes
Loading of a flash video on a webpage
Scrolling down the page
Viewing of a flash video
Viewing video footage of certain length
Clicking on a video’s play/pause/stop button
Interaction with a gadget
Clicking on an image or a link
Abandonment of a form
Log-ins
Sharing/printing a blog post, article, video or image

There are two types of events in Google Analytics:

1. One which generate pageviews when they occur like clicking on an internal link on a webpage. In this case Google Analytics calls the _trackPageview() method each time such event occurs.

2. One which doesn’t generate pageviews when they occur like: clicking on an external link, loading of Ajax/Flash content, downloading a file, viewing of a video, clicking on a video’s play button etc. In this case Google Analytics doesn’t call the _trackPageview() method each time such event occurs.

By default Google Analytics (GA) can’t track any event which doesn’t generate pageview when it occurs like: clicking on an external link, viewing of a flash video, downloading a file etc.

You can track such events only through virtual pageviews or event tracking.

An event in event tracking reports of GA is made up of: Category, Action, Label and Numerical value.

I will discuss them in detail later. Now lets start with virtual pageviews.

A virtual pageview is a pageview which google analytics can track even when no new web page has actually been loaded into the browser.

 

Generating Virtual Pageviews

You can generate virtual pageviews by calling _trackPageview() method each time the event you want to track occurs.

Syntax: ­­_gaq.push ([‘_trackPageview’,’name of your virtual page’]);

Examples:

<a href=”http://www.abc.com/gu/dw/seo-beginners-guide.pdf” onClick=”_gaq.push ([‘_trackPageview’,’/virtual/guides/download/seo-beginners-guide.pdf’]);”> Download SEO Beginners Guide</a>

<a href=”http://www.abc.com/gu/dw/social-media-guide.pdf” onClick=”_gaq.push ([‘_trackPageview’,’/virtual/guides/download/social-media-guide.pdf’]);”> Download Social Media Guide</a>

So when a user clicks on the link ‘Download SEO Beginners Guide’, GA will generate a virtual pageview called ‘/virtual/guides/download/seo-beginners-guide.pdf’. You can see this virtual pageview in  in ‘All Pages’ and ‘Content Drilldown’ reports (under Behavior > Site Content) in your Google Analytics account along with the real page views.

Similarly, when a user clicks on the link ‘Download Social Media Guide’, GA will generate a virtual pageview called ‘/virtual/guides/download/social-media-guide.pdf’.

 

Naming Conventions for Virtual Pageviews

You can also name your virtual pageview something like ‘social media guide’ instead of ‘/virtual/guides/download/social-media-guide.pdf’. However I prefer the latter name because:

1. I want to group all virtual pageviews into categories by making them a part of a virtual directories:

virtualPageview-Naming

2.  I want to use a clear naming convention for virtual pageviews so that I can easily distinguish them for other virtual pageviews and regular pageviews in my Google Analytics reports.

 

You can call _trackPageView() method using a JavaScript handler like onClick, onSubmit etc.

You can create a virtual page view wherever you can call a JavaScript method.

You should track those types of events using virtual pageviews which are equivalent of a page being viewed like:

  • downloading a file
  • loading of Ajax, JavaScript or flash contents
  • loading of a dynamically generated webpage
  • loading of pop-ups, light boxes
  • scrolling down a page etc.

You can see virtual pageviews in ‘All Pages’ and ‘Content Drilldown’ reports in Google Analytics along with the real page views. However you need to remember that:

‘virtual page views’ are not highlighted as ‘virtual’ in the Google Analytics reports and you will have to use proper naming convention and filter on the reporting interface to find them.

So the question is

How you can distinguish virtual pageviews from real pageviews in GA reports?

To do this start your virtual page name by ‘virtual’ and then search for ‘virtual’ using filter on the reporting interface. In this way you can easily spot virtual pageviews in GA report. For example:

virtual

Searching for Virtual Pages in Google Analytics reports

One disadvantage of using virtual page views is that it can artificially inflate your overall pageviews.

Note: GA also calls the trackPageview() method in GATC (Google Analytics Tracking Code) each time a page is loaded by the browser. This method is called immediately after the _setAccount() method in GATC.

For example:

_gaq.push ([‘_setAccount’,’UA-12345-1’]);

_gaq.push ([‘_trackPageview’]);

Best practices for creating virtual pageviews

1. Use clear and consistent naming conventions for your virtual pages.

2. Start your virtual page name with the word ‘virtual’ so that you can easily spot them in the GA report.

3. Create one or more virtual directories to categories your webpage elements. For e.g.

gaq.push ([‘_trackPageview’,’virtual/guides/downloads/seo-beginners-guide.pdf]);

4. Create a separate view (or profile) just to track virtual pageviews.

 

Setting up virtual pageviews as goal

You can set virtual pageviews as a goal in your Google Analytics account. To do this follow the steps below:

Step-1: Log in to your GA account and click on the ‘Admin’ link at the top right.

Step-2: Click on the ‘Goals’ link:

goals-link

Step-3: Click on ‘+New Goal’ button.

Step-4: Click on ‘custom’ from the ‘Goal setup’ options:

custom-goals

 Step-5: Click on the ‘next step’ button. Enter the name of your goal and select ‘destination’ as goal type:

pageviews-goal

Step-6: Click on the ‘next step’ button, enter the URI (URL without the domain name) of your virtual page view, specify the goal value and then click on the ‘Create Goal’ button:

virtualGoal-setup

 

Virtual pageviews are ideal for tracking goals or funnel pages hosted on a different website.

funnel-steps

To learn more about setting up goals and funnel steps in Google Analytics, check out this post:

The Geek Guide to Understanding Funnels in Google Analytics

 

Tracking Virtual Pageviews in Universal Analytics

The syntax for tracking virtual pageviews in Universal Analytics (UA) is different.  To generate virtual in Universal Analytics you do not call the _trackPageview() method each time the event you want to track occurs.

Follow is the syntax for tracking virtual pageviews in UA: 

ga(‘send’, ‘pageview’, ‘name of your virtual page’);

Examples:

<a href=”http://www.abc.com/gu/dw/seo-beginners-guide.pdf” onClick=”ga(‘send’, ‘pageview’, ‘/virtual/guides/download/seo-beginners-guide.pdf’);”> Download SEO Beginners Guide</a> 

<a href=”http://www.abc.com/gu/dw/social-media-guide.pdf” onClick=”ga(‘send’, ‘pageview’, ‘/virtual/guides/download/social-media-guide.pdf’);”> Download Social Media Guide</a>

 

So when a user clicks on the link ‘Download SEO Beginners Guide’, UA will generate a virtual pageview called ‘/virtual/guides/download/seo-beginners-guide.pdf’.

Similarly, when a user clicks on the link ‘Download Social Media Guide’, UA will generate a virtual pageview called ‘/virtual/guides/download/social-media-guide.pdf’.

Note: The naming conventions and best practices for virtual pageviews in UA are same as they are in GA.

Similarly, setting up virtual pageviews as goal in UA is same as setting up virtual pageviews as goal in GA.

 

Setting up Event Tracking in Google Analytics

You can set up event tracking in GA by calling _trackEvent() method each time the event you want to track occurs. This method is used to record/track an event.

Syntax: ­­_gaq.push ([‘_trackEvent’,’event category’,’event action’,’event label’, event value, opt_nonInteraction]);

Event Category => It is the name given to group of similar events which you want to track. For e.g. ‘videos’

Event Action => It is the name given to the type of event you want to track for a particular webpage element. For e.g. ‘play’, ‘stop’, ‘pause’, ‘share’ etc.

Event Label => It is used to provide additional information about the webpage element you want to track like: title of a video, name of a gadget, name of the downloadable file etc.

Event Value => It is the numerical value assigned to the event you want to track. For e.g. download time, length of the video footage played or some dollar value.

opt_NonInteraction => It is used to designate an event as interactive or non-interactive. This parameter has two values: true and false. The default value is false which means by default an event is considered as interactive and it impacts the bounce rate calculations. If you want to make an event non-interactive so that it doesn’t impact the bounce rate calculations then set the opt_nonInteraction value to true.

 

Specifying ‘event category’ and ‘event action’ in _trackEvent() method is mandatory.

Whereas, specifying ‘event label’, ‘event value’ and opt_NonInteraction in _trackEvent() method is optional. 

Examples:

To track the clicks on the link ‘Download SEO Beginners Guide’ , you would place the event tracking code like this:

<a href=”http://www.abc.com/gu/dw/seo-beginners-guide.pdf” onClick=”_gaq.push ([‘_trackEvent’,’guides’,’download-seo’,’seo-beginners-guide.pdf’,10, true]);”>Download SEO Beginners Guide</a>

Note: Here I have set opt-NonInteraction value to true. So now the tracked event will not impact the bounce rate calculations.

 

To track the clicks on the link ‘Download Social Media Guide’ , you would place the event tracking code like this:

<a href=”http://www.abc.com/gu/dw/social-media-guide.pdf” onClick=”_gaq.push ([‘_trackEvent’,’guides’,’download-social’,’social-media-guide.pdf’,10]);”>Download Social Media Guide</a>

 

Note: There is a disadvantage of using duplicate ‘event action’ names across categories. The disadvantage is that: 

Unique events are incremented by unique action names.

So if a user clicks on two different videos say ‘spiderman-2’ and ‘Aliens vs predator’ which have same action name say ‘play’, then in that case GA will report only one unique event even when the user clicked on two different videos.

So action names should be unique. For e.g.

_gaq.push ([‘_trackEvent’,’videos’, ‘play-spiderman’,’Spiderman-2’,10]);

_gaq.push ([‘_trackEvent’,’videos’, ‘play-dog-out’,’Who lets the dog out’,10]);

_gaq.push ([‘_trackEvent’,’videos’, ‘play-aliens-predator’,’Alien vs predator’,10]); 

 

You can call _trackEvent() method using a JavaScript handler like onClick, onSubmit etc.

You can record an event wherever you can call a JavaScript method.

You should track those type of events using ‘event tracking’ which are not equivalent of a page being viewed like:

  • viewing of a flash video
  • viewing video footage of certain length,
  • clicking on a video’s play/pause/stop button
  • interaction with a gadget
  • clicking on an image or a link
  • abandonment of a form
  • log-ins, sharing/printing a blog post, article, video or image etc.

You decide the reporting structure through arguments of _trackEvent() method.

You should avoid tracking highly repetitive events like mouse movements because GA can’t track more than 500 events per visit.

 

Setting up Event Tracking in Universal Analytics

The syntax for setting up event tracking in Universal Analytics (UA) is different. To record/track an event in Universal Analytics, you do not call the _trackEvent() method each time the event you want to track occurs.

Follow is the syntax for tracking events in Universal Analytics:

Syntax: ga(‘send’, ‘event’, ‘’event category ‘, ‘event action’, ‘event label’, event value, {‘nonInteraction’: 1});

Here {‘nonInteraction’: 1} is used to designate an event as non-interactive.

Note: Specifying ‘event category’ and ‘event action’ is mandatory. Whereas, specifying ‘event label’, ‘event value’ and nonInteraction is optional.

 

Examples:

To track the clicks on the link ‘Download SEO Beginners Guide’, you would place the event tracking code like this:

<a href=”http://www.abc.com/gu/dw/seo-beginners-guide.pdf” onClick=”ga(‘send’, ‘event’, ‘guides’, ‘download-seo’, ‘seo-beginners-guide.pdf’, 10);”>Download SEO Beginners Guide</a>

 

To track the clicks on the link ‘Download Social Media Guide’, you would place the event tracking code like this:

<a href=”http://www.abc.com/gu/dw/social-media-guide.pdf” onClick=”ga(‘send’, ‘event’, ‘guides’, ‘download-social’, ‘social-media-guide.pdf’, 10);“>Download Social Media Guide</a>

 

Other examples:

Tracking Clicks to Emails

Let us suppose you want to track clicks on the email address: himanshu@google.com

Check the source code of the web page where this email address has been embedded and then replace the following line of code:

<a href=”mailto:himanshu@google.com”> himanshu@google.com </a>

with

<a href=”mailto: himanshu@google.com ” onClick=”ga(‘send’, ‘event’, ‘Email’, ‘click to email’, ‘himanshu@google.com’);”> himanshu@google.com </a>

Here,

  1. ‘Email’ is the event category
  2. ‘click to email’ is the event action
  3. ‘himanshu@google.com’ is the event label.

 

Note: You need to make these changes site wide wherever you have placed email addresses.

If you want to use another email address like say matt@google.com then the event tracking code will be:

<a href=”mailto: matt@google.com” onClick=”ga(‘send’, ‘event’, ‘Email’, ‘click to email’, ‘matt@google.com’);”> matt@google.com</a>

So syntax for tracking clicks to emails would be:

<a href=”mailto:INSERT YOUR EMAIL ADDRESS” onClick=”ga(‘send’, ‘event’, ‘Email’, ‘click to email’,’INSERT YOUR EMAIL ADDRESS’);”>INSERT YOUR EMAIL ADDRESS</a>

 

 

Advantage of using Event Tracking over Virtual pageviews

1. Event tracking doesn’t artificially inflate your overall pageviews.

2. Through event tracking reports you can analyze events in much greater details. For e.g. not only you can track how many times people watched your video but you can also track what was the effect of video viewing on your site usage and e-commerce metrics.

 

Best practices for setting up event tracking

event-naming-conventions

1. Use clear and consistent naming conventions for event categories, event actions and event labels.

2. Determine in advance all of the web page elements (like videos, gadget, image, external link etc) and the type of events you want to track.

3. Create a hierarchy of event categories, event actions and event labels that is scalable. Then work with your report users to make sure that your hierarchy is understandable.

 

Event Tracking Reports

The Event tracking reports are available under the ‘Behavior’ report in Google Analytics. There are 4 event tracking reports available in Google Analytics:

  1. Overview report
  2. Top Events report
  3. Pages report
  4. Events Flow report

 

Event Overview report

event-overview-report

event-overview2

This report provides overview of tracked events on your website like:

  1. Total events
  2. Unique events
  3. Event Value
  4. Avg. Value
  5. Visits with event
  6. Events/visit
  7. Top events

Total events => It is the total number of users’ interaction with tracked webpage elements. It is also the total number of times the _trackEvent() method was called.

For e.g. if a visitor clicks on the ‘play’ button of a same video 5 times, then GA report total events as 5 but unique events (number of unique interactions that occurred in a web session) as 1.

Event Value => It is the total value of an event or set of events.

Avg. Value => It is the average value of an event.

Visits with event => These are those web sessions in which at least one tracked event occurs.

Events/visit => It is the number of tracked events that occurred in a web session.

Top Events Report => This report includes top event categories, top event actions and top event labels.

Event Category - Through this report you can determine the categories of the recorded/tracked events. Click on a category in the table to see the event actions or event labels for that category.

Event Action - Through this report you can determine the actions of the recorded events. Click on an action in the table to see the event label or event category for that action.

Event Label - Through this report you can determine the labels of the recorded events. Click on a label in the table to see the event action or event category for that label.

 

Event Pages report - Through this report you can determine the web pages on which the events were tracked/recorded. You can also determine the site usage (average visit duration and % new visits) on these web pages.

Events Flow report -  Through this report you can visualize the order in which visitors triggered events on your website. Check out the video below to learn more about events flow report:

Through event flow report you can determine the category of events that are more popular than other events.

You can determine the contents which keep visitors engaged with your website. In this way you can develop contents which provide similar level of user engagement.

In order to interpret the events flow report accurately, it is critical that you use clear and consistent naming conventions for event categories, actions and labels.

Configuring the Events Flow report includes:

Examining Nodes and Connections
Applying Default or Advanced Segments
Comparing Data of different time range
Selecting Dimensions
Exporting the events funnel report etc.

You can learn more about this configuration from here.

 

Automating and Scaling Event Tracking

event-automation

So you need to automate and scale your event tracking process. You need to find ways through which you can do large amount of event tracking in reasonable amount of time. You can learn more about scaling and automating event tracking from this post:

Learn to Automate Event Tracking in Google Analytics

 

 Related Posts

Join over 4000 subscribers!
Receive an update straight to your inbox every time I publish a new article.

 

About the Author:



My business thrives on referrals, so I really appreciate recommendations to people who would benefit from my help. Please feel free to endorse/forward my LinkedIn Profile to your clients, colleagues, friends and others you feel would benefit from SEO, PPC or Web Analytics.

 

 

  • http://antennainstallationssydney.com.au/ Phil

    Can I use this to track banner ads on my site? Is it simple to do for a non coder, am on wordpress. Cheers Phil

    • seo himanshu

      Yes you can track banner ads and you don’t need to be a coder for that. Thanks for stopping by.

      • Lav

        Hi Himanshu,

        I need a quick help from you..

        just working on a project, where i need to track the top 10 items viewed on a page, where the page may be available at any depth level.

        For ex. home->content
        suppose in content page i have around 20 files (pdf) listed and i need to track, the top 10 files visitor’s visit in that page.

        Kindly suggest me a solution asap.

        Thanks

        • seohimanshu

          You need to read this post on automating and scaling event tracking: http://www.seotakeaways.com/how-to-automate-event-tracking-google-analytics/

          • Lav

            Hi thanks for your quick reply.
            I have gone through the entire link and got very useful details.

            Need to ask you one more thing, like how can i track the files viewed inside a particular link of a particular page.

            Ex- suppose i have a page called as content and inside content i have a link called us ‘click to see files related to machines’, so when i click this link, i will be redirected to another page called as ‘details’ page and their all my files are listed related to machines. so now i need to track top 10 files viewed among that listed files.

            Please reply me on this.

            Thanks in advance.

            • Lav

              Do i need to create any custom reports and add filters in that to execute this task?

            • seohimanshu

              I can’t answer this question in a comment box. It is too technical but in short you can track the scrolling of the ‘details’ page.

              • Lav

                Oh thats good. Thanks for you reply….

                But your articles in this website are really great, i can say as you have clearly explained everything and also in a easy language which is really good.

  • http://Website Jonathan

    Good stuff on event tracking. How about a similar post on omniture?

  • http://Website lbcod

    How can i track form submissions using virtual pageviews? Thanks.

    • seo himanshu

      When a person clicks on the form ‘submit’ button, call the _trackPageView() method to generate a virtual pageview.

  • http://Website Eric

    I have a short question on this. Can i define event as a goal?

    • seo himanshu

      Yes you can through virtual pageviews.

    • http://asdruble.com.br Bruno Davico Simões

      now on the new updated version… YES YOU CAN!

  • http://Website Karl

    Hey thanks for writing such a wonderful post on event tracking and virtual pageviews. Can you tell me how bounce rate is calculated in case of event tracking? Thanks again.

    • seo himanshu

      Hi Karl! . Event tracking may reduce the bounce of an event enabled page if an event occurs on the page (like a video is played). This is because in this case GA will send two GIF requests to the GA server. One request will be sent as soon as the page is loaded into the browser and another request will be send when the tracked event occurs. Two GIF requests will make a visit non-bounce visit.

  • http://Website David

    This is cool. Where i can see actual working examples of event tracking?

  • http://Website Robbin

    The bounce rate of my event enabled page is always 0%. Help please?

    • seo himanshu

      An event enabled page has 0% bounce rate when the tracked event occurs as soon as the page is loaded. For e.g. a video started playing automatically as soon as you load the page. In this case GA will always send two GIF requests to the GA server and hence visit will always be ‘non-bounce’ visit. So you need to stop any such event which starts automatically as soon as the page is loaded.

  • http://Website Sean

    Thanks for sharing the post. I have set up event tracking but my reports are not showing any results. Any idea???

    • seo himanshu

      Please check the syntax of your _trackEvent() method and make sure that your JavaScript handler is working.

  • http://Website Jitender

    Thanks for the guide Himanshu. i will try it on my site. By the way how your exam preparation is going on. You seem well prepared after I see you come with such superb post on Google Analytics.

    • seo himanshu

      Preparation is ok. I am desperate to get the certification now :)

  • http://Website Richard Burton

    Another useful post, will definitely be using it.

  • http://Website Miranda

    This is a brilliant post on event tracking and easy to understand. Much better than the official Google Version. Thanks a lot.

  • http://Website Steve

    Good to hear from you again and this time on analytics :)

  • http://Website John

    Thanks for explaining it in the real world language. I struggled with events for quite some time. Cheers!

  • http://Website ChrisrockSEO

    Great post. I don’t know a lot about event tracking. The Google version put me off. Very much appreciated.

  • http://Website seo-god

    love the advanced information on google analytics. keep writing posts like these.

  • http://Website rupesh82

    Very nicely put info on event tracking and pageviews.

  • http://Website Vinay Gupta

    Love Google Analytics. Can you share some live examples?

  • http://seo.tolafamakinwa.net/ Tola

    Hi Himanshu,
    Great post as usual! And very timely for me as well, I’ve just been having some annoying issues with my pageview and then you mentioned filtering the virtual pages, I’m off to do that now. Thanks for that…

    On another note, I think it would be a good idea to add your twitter account name to your retweet button so it’s easier to see your tweets… Just a thot :-)

    • seo himanshu

      Thanks for the tip. I will do that asap.

  • http://www.countryclubindia.net/ Ali

    Hi, Himanshu,
    Great information about Event tracking, Actually I am trying to learn Event tracking but, Don’t know where to insert the link, I checked with Google codes also, but not got the clear picture, on how to track…

    Example,
    unaudited finance Art work

    but don’t know where to keep this hyper-link on the event tracking page, just need to give anchor links on tracking page, or anything else need to do….

    Need Ur help…in this….

    • seo himanshu

      You can place your links wherever you like. You just need to use the javascript handler onClick in your <a> tag to call the _trackEvent() method. For e.g.

      <a href=”http://www.abc.com/invester_guide.php” onClick=”_gaq.push (['_trackEvent','guide', 'click on investor guide', 'investor-guide.php']);”>Download Invester Guide</a>

      • anuradha

        Hi himansu,
        will just let me know how to track offline events/conversations?i mean user is not having internet connection but still playing with an application(in my case it would be localhost URL).Immediate response is apprecialtable.
        Ned your help .

        • optimizesmart

          you can’t track offline events in Google Analytics.

  • http://Website Ana

    This is amazing, so far the easiest tutorial I’ve found. I am pretty new at this though and I was wondering what would be the code to even-track a banner ad.

    My blog is http://www.liveandenliven.com/ the banners are on the bottom right and even though I added a code. Like this one:

    Nothing shows on my analytics account. Please help!? I am huge need! I have to report the clicks in a few days and I’ve got nothing to work with :(

    • seo himanshu

      Hi Ana! Make sure that you are using the JavaScript handler correctly. Like onClick, instead of onclick. Also check the syntax of your _trackEvent method. If this method is not called when the tracked event occurs on your page, then you won’t see any data in Google Analytics Event Tracking Reports.

      • http://Website Ana

        Thanks so much! … In case I mess up… do you freelance?

      • http://Website Ana

        Oh and to track banner ads do I change “Download Social Media Guide” for the image code? THANKS!

        • seo himanshu

          yes.

  • http://Website Analytics Nerd

    Excellent post Himanshu.

  • http://Website SpanishSEO

    This is the quick and easier way to learn event tracking. A very relevant post esp. for us as we are jumping into the CRO industry. Thanks.

  • http://Website Gari

    Event tracking is wonderful. It adds a completely new dimension to your analytics. For the first time we were able to track file downloads.

  • http://Website rogue-seo

    Hi! Can i use event tracking as one of the funnel visualization step? Very useful post. Thanks.

  • http://Website Marco

    Nice overview of event tracking. Well done. Anlaytics is still a complex topic for me.

  • http://Website Tyler

    I have been using event tracking for a while now. Your post helped me in understanding this topic better. Thanks.

  • http://Website JanetSEO

    Once again an incredible post from your side. I have not started doing event tracking yet. But this post will certainly help me.

  • http://Website Peter Silva

    This is really helpful stuff on event tracking and pageviews.

  • http://Website livelybrowsers

    Thanks for good stuff

  • http://Website Sajeet

    Hey,

    Good post himanshu, I was wondering how will we track
    Pause and play events I.e. using event tracking
    Will I be able to find how many people watched
    A complete video or paused in between?

    • seo himanshu

      Yes you can find out how many people watched the complete video or paused it in between. For this you need to add the _trackEvent() method to the play/pause button using a javascript handler like onClick.

  • http://Website Sajeet

    I guess i am a little confused, correct me if i am wrong but this is how my parameters will look like –
    Category – Video
    Action – Play
    Label – Video Name
    Value – 2

    So when i add trackEvent() method i will probably know how many people clicked on play button, but using this method how will i know if they watched the complete video or when they paused?? Also can you please tell me the significance of the parameter “Value”

    • seo himanshu

      Hi Sajeet!
      To determine how many people watched the complete video or any length of video you need to know javascript or some other scripting language. Create a variable in javascript which can calculate the length of the video played. Then use the variable declared in your script as a ‘value’ in your _trackEvent() method. For e.g. _gaq.push ([‘_trackEvent’,’videos’, ‘play-spiderman’,’Spiderman-2’,videoLengthPlayed]); I hope this helps.

      • http://www.facebook.com/profile.php?id=100003405474410 Rian

        Thanks for the guide Himanshu. i will try it on my site. By the way how your exam ptrapraeion is going on. You seem well prepared after I see you come with such superb post on Google Analytics.

      • Manoj

        How can you track the time a user spent viewing your video if suppose he clicks on Play button and closes the browser or navigates to other page?

        • http://www.seotakeaways.com/ Himanshu

          If a visitor closes his browser or navigate to another page then the video will stop playing. To determine the length of video being watched you need to know javascript or some other scripting language. Create a variable in javascript (say ‘videoLengthPlayed’) which can calculate the length of the video played. Then use the variable declared in your script as a ‘value’ in your _trackEvent() method. For e.g. _gaq.push ([‘_trackEvent’,’videos’, ‘play-lord-of-the-ring’,’LRD-2’,videoLengthPlayed]);

  • http://betterretail.wordpress.com Rishi Rawat

    Hi Himanshu,

    Great article. Your article is more lucid than the one on Google (http://code.google.com/apis/analytics/docs/tracking/eventTrackerGuide.html)!

    Can you share code example for tracking “abandonment of a form”?

    Thanks,
    Rishi

    • seo himanshu

      Hi Rishi! Here is the example code for tracking abandonment of a form:

      <input name=”first_name” onChange=”_gaq.push ([‘_trackEvent’,’forms’,this.form.action,this.name]);” />

      This code is for the input field ‘First Name’ in a form. You can develop similar code for other fields in a form.

      • http://betterretail.wordpress.com Rishi Rawat

        Ah, I get it!

        Suggestion- you should add a checkbox for “Notify me of followup comments via e-mail”. I was about to miss your reply.

        Thanks!

      • Muhammad

        Excellent read, I just pasesd this onto a colleague who was doing a little research on that. And he actually bought me lunch because I found it for him smile So let me rephrase that: Thanks for lunch!

  • http://betterretail.wordpress.com Rishi Rawat

    You added “Notify me of followup comments via e-mail” checkbox. Awesome.

    • seo himanshu

      Yes i do take suggestions seriously :)

      • http://betterretail.wordpress.com Rishi Rawat

        :)

  • http://Website Alex

    Hi Himanshu,

    Do you know if there is another method to track events without generating a virtual page view ? I suppose that yes because I red it somewhere. It seems that I must change tracking code. It gives something like this

    onclick=”_gaq.push(['pageTracker._trackEvent', 'event name', 'event name']);”

    Can you tell me if the code above is good ?

    Thank you

    • seo himanshu

      No the code is not good. The correct one is:
      onclick=”_gaq.push ([‘_trackEvent’,’event category’,’event action’,’event label’, event value]);”

  • http://www.windfery.com Windfery

    Awesome post!

    I’m attempting to track form abandonment rates with the following methodology

    form, formName, fieldName, error

    a successful entry of the email field would look like
    _gaq.push(['_trackEvent', 'form', 'contactUs', 'title',1]);

    whereas an email validation error would be:
    _gaq.push(['_trackEvent', 'form', 'contactUs', 'title',0])

    i’m trying to make an advanced segment that only shows “email” label with value of “1″. however, I think that filter is only reading the aggregate label value instead of individual values. you come across this?

    cheers

  • http://Website Mohit

    Hi,
    First of all, great post. I was wondering if Event tracking can be used for elements excepts the ones which are hyperlinked. For instance, how can I use the same tool to register a successful login?

    Thanks

    • seo himanshu

      HI Mohit!
      Through event tracking you can track how many people clicked on the login link/button. To track successful logins you just need to track the page which is a served to a visitor immediately after successful log in.

  • Pisces

    Hi,

    I have a conversion flow that goes like this:
    Yahoo PPC >> promotion landing page on my http site >> contains an APPLY button >> another domain (a secured https site) to fill up their details >> click SUBMIT >> “Thank You” page in the secured domain

    I need to craft an end-to-end report in Google Analytics but am not sure whether I should be setting events (buttons) or goals (page). And whether I need to do cross domain tracking since there are more than 1 domain (one http, the other https)

    For your advises, pls.

    • http://seohimanshu.com/about-himanshu/ seo himanshu

      You should implement both event tracking and cross domain tracking. Track the event when someone clicks on the ‘Apply’ button and also when someone clicks on the ‘submit’ button of the other website. You can then see this conversion flow through Multi channel funnel reports in the new GA interface.

  • Pisces

    Thanks. I have the pages tagged. But so far, I can only get data for the SUBMIT (on https site) event and not the APPLY (on http site) event. The codes are similar as follow

    Am I missing anything?

  • http://seoinspection.com Google Traffic

    You show in your example to push a url with virtual/ as the first level.
    I wonder if instead you could use a url parameter?

    Would the virtual/ force your reports to have one additional level all the time?

    Do parameters get sent as well?
    ex:
    virtual/guides/downloads/seo-beginners-guide.pdf?camp=AA82011

    • http://seohimanshu.com/about-himanshu/ seo himanshu

      I don’t see any problem why they won’t.

  • http://in.linkedin.com/in/googlewebanalyticsconsultant Mridul Gupta

    Thanks for sharing a great stuff.
    What is the main difference between pageview and virtual pageview?
    I think tacking code for both is almost same..

    • http://www.seotakeaways.com/ Himanshu

      virtual pageviews are not the actual pageviews which occurs only when a user loads a page. They can occur even if a visitor doesn’t load a page.

  • rashmi

    So are there situations in which the unique events number in the category report in GA greater than the highest unique events # for the events within that category. For example:
    unique events at the report = 60
    My event data:
    pop up displayed – 50
    field missing – 10
    item x selected – 16

    So why is my unique events # at the top of the report – 60? Shouldn’t it be 50?

  • http://cheaptilerwakefield.com JD

    Hi Himanshu,
    Fantastic blogg so much easier to understand than own googles info,
    just a quick question I have a flash 3D carousel for my banner in wordpress but the images/SWF’s are loaded in by XML and am trying to add Event Tracking to them any ideas.

    Kind regards JD

    • http://www.LAokay.com Steve G

      Modify your widget and call the event tracker whenever the event you want to track happens. You do know javascript right?

  • http://zaichina.net Daniel Mendez

    Hi! Thank you very much for this amazing tutorial. The explanation is much better than the official one at Google. Great, useful, amazing explanation.

    I´ve seen that some readers before me had problems with how to track a banner, which is the situation I´m in right now. I don´t really know where and how to include the code. For example, this is the code for my ad banner:

    The only think I would like to know is how many people click on the ad and go the company´s website. How can I track that? Thank you very much for your time and help.

    • http://www.seotakeaways.com/ Himanshu

      Hi Daniel! Thank you for stopping by my blog. Unfortunately my spam filters filtered out your code. To track clicks on your banner all you need to do is add the _trackEvent() method to your banner using a javascript handler onClick. For example:

  • Manoj

    Great blog Thanks for Sharing!
    I am having a issue to track how many users view a video on the page, how many users click the play button. I would also like to track the video time viewed by the users in case he play s the video and either closes the browser or navigates to another page. Is this possible?

    Thanks,
    Manoj

    • http://www.seotakeaways.com/ Himanshu

      See my answer above. you need to add the _trackEvent() method to the play/pause button using a javascript handler like onClick.

  • http://montreal.inseoservices.com IN SEO Services

    Thanks you very much for your interesting post on Analytics Track Event, I have to tried that in my site.
    Its possible to use in and ecommerce site also?
    Thanks,

    Francisco

    • http://www.seotakeaways.com/ Himanshu

      You can use event tracking in all types of websites including e-commerce.

  • Chris

    Great post! I am having some trouble adding the tracking code to a submit button in a CMS. The issue I have is that I cannot place the tracking code in the html code directly. Do you know of a way of targeting the submit button through javascript? I found a way through jQuery, but the site is already using prototype(adding scripts to the is not a viable option). I am using is the traditional code, not the asynchronous:

    onSubmit=”pageTracker._trackPageview(‘/virtual/quote-submit’);”

    Let me know if you have any suggestions. Thanks in advance!

    • http://www.seotakeaways.com/ Himanshu

      Hi Chris,

      Which CMS you are using? I know that the CMS like ‘Volusion’ doesn’t allow putting event tracking code.

  • jake

    Thanks for the informative article, but I can’t tell if the info is out of date or not because your page doesn’t have a post date that I can find. When was this written and does the information presented still hold up?

    • seohimanshu

      absolutely. Every post on this website is a living document and is constantly updated.

  • KD

    I wonder if you could help me with a form event tracking issue, I can’t seem to find any information about. I’ve often used event tracking in the past for links, but I’m not
    sure how to implement event tracking to measure my form abandonment.

    I want the category to be Forms, the action to reflect a completed
    selection, and the label to be ‘Region – United States’ for example.

    Select a Region

    Please Select Region

    United States

  • Jason

    Just a heads up, the syntax for asynch page view tracking is “_gaq.push(['_trackPageview',yourpathhere]);” with a lowercase “v”, not an uppercase. That tripped me up for a bit.

    Also, the Google Analytics debugger for Chrome is a fantastic resource to use while developing your GA implementations:

    https://chrome.google.com/webstore/detail/google-analytics-debugger/jnkmfdileelhofjcijamephohjechhna?hl=en

    • seohimanshu

      Thanks for the heads up.

  • Katrina Moody

    Best article I’ve read on this so far but I am still trying to understand … if, for instance I wanted to track clicks on the submit button on my Aweber form (so I have a different tracking mechanism than just Aweber’s) – how would I add the tracking info to my button?

    • seohimanshu

      You can add tracking code on a third party button only if they let you do that. Generally it is not possible as then they have to give you access to their source code.

  • Lav

    Hi Himanshu,

    I need a quick help from you..

    just working on a project, where i need to track the top 10 items
    viewed on a page, where the page may be available at any depth level.

    For ex. home->content
    suppose in content page i have around 20 files (pdf) listed and i need to track, the top 10 files visitor’s visit in that page.

    Kindly suggest me a solution asap.

    Thanks & Regards

  • Lav

    Hi Himanshu,

    Can you tell me , how can i track , how many people have subscribed for a blog through RSS feed and how many through email?

    • seohimanshu

      You can track RSS feed subscribers through feedly and email subscribers through feedburner.

      • Lav

        thanks for your reply…

  • Guest

    hi himanshu,

    Do we need to compulsory create a goal after applying the tracking code to my tags.means is it necessary to associate my tracking code for pdf downloads with a goal?

    • seohimanshu

      Creating goal is not compulsory. But you would track something only when it is important for you and if it is important than you would like to track it as a goal.

  • Lav

    Do we need to compulsory create a goal after applying the tracking code to my href tags.means is it necessary to associate my tracking code for pdf downloads with a goal?

    • seohimanshu

      no it is not necessary.

  • Lav

    Hi (A) can, we track the visitors subscribing for blogs through either rss feed or through email, using google analytics event tracking code without using feedburner or any other thirds party tool.

    (B) can you suggest the approach or method to track the visitors and subscribed blogs titles through rss feed or through email using goals or conversions?

  • Lav

    Hi, Is it possible to get visitors details by industry/organization in google analytics ?

    Can we get visitors location on a smaller scale i.e. lesser then city i.e. USA -> Chicago – > naperville, so here i need to see “neperville” in my google analytics report. Is it possible to do this?

    Please reply for this.

    • Lav

      Please reply for my query..

      • seohimanshu

        No it is not possible

        • Lav

          Hi Thanks himanshu for your reply.

  • alds

    Great article Himanshu! Probably the best article out there about Event Tracking. Other articles just tell you how to put the code, but not how to understand it. You did the latter well. Thanks a lot!

    BTW, can you include the date in your posts? As practices, trends, and software change, the date would provide context on how applicable/relevant the articles still are.

  • Dipanshu gupta

    Hi,Nice article…but i have some issue in google analytics,I wan to track my website on some specific conditions like…how many people click on Sign Up button direct and how many people click on Sign Up button after click on some link..and this link is open a jquery popup.Please help me with same.thank you

    • seohimanshu

      Go to ‘Top Events’ report in your Google Analytics account. Select ‘Event Action’ as primary dimension and ‘source/medium’ as secondary dimension.

      • Dipanshu gupta

        Himanshu,Thanks for your reply but i think its not relevant what i was asking…please help me.1:- I want to track those visitor who click on sign up button directly without click on any link.2:- How many visitor click a link and then click sign up button.This is actual requirement please share your experience.Thanku

        • seohimanshu

          1. Set up event tracking code on the signup button.
          2. I have already answered this question. If still in doubt, read the chapters at google analtics academy and go through GAIQ lessons.

  • Jack

    Hi Himanshu,

    Great article on Google Analytics but do you know how to track download clicks in Google Universal, if yes then can you share an example

  • Peter Kirwan

    Hi Himanshu, very helpful post as always. I’ve made a slight mistake with mine and wanted to check I was stuck with the results. Because site is non-e-commerce I deliberately didn’t specify a value in the tracking code and didn’t specify one in the goal set up. About a week later I realised having a hypothetical value would make looking at assisted conversions and such a lot easier and so I changed the goal value and added in a value to the tracking code. Works fine for new events but for my old events I appear to be stuck with them having no value. Just wanted to check I’m stuck and there was no way to get the old events to show up with that value in reports. So I’m stuck right? Thanks as always. PeterK

    • seotakeaways

      Hi Peter! Sorry for the late reply. Somehow I missed this comment. Yes you can’t change the value for your event goals which have already been recorded by Google. But it is better late than never.

      • Peter Kirwan

        indeed! thanks for the reply :)

  • http://www.interdigitalmarketing.com/ Vikas Rathee

    Is this mandatory to add the analytics code in website header. I added the GA analytic code in footer and created many event. But i am not able to see anything in google analytics report. Can you please suggest if i am missing something :

    GA Code : http://www.pricingindia.in
    Event code : onerror=”_gaq.push(['_trackEvent','mainimage','failed','pageid'])”

  • Manoj

    Very neatly explained. Thanks Himanshu.

    • seotakeaways

      Thank you.

  • Guillaume Laurier

    Hi Himanshu,

    How do I set up a Goal with dynamic Virtual pageviews. Like if my virtual pageview include a User ID and a session # i.e. _gaq.push([‘_trackPageview’, ’7525528,2014-03-27_20:18:17,01215,0,6,download-office-release-notes,0,vp-http://www.example.com/downloads/office/notes.

    Thanks

  • Tony Day

    Which one to use virtual Page or Events?

    • seotakeaways

      Events majority of the time.

  • Sagar Ubhare

    i have added the Event code as you have mentioned but how do i enable event tracking in Google analytics

    • seotakeaways

      if you have set up event tracking code correctly then you can see the event data in events report under ‘behavior’ section in your GA account.

  • http://www.designingsean.com Sean Ryan

    In your article, you say the following: “Unique events are incremented by unique action names.” Do you know if this is still true with Universal Analytics?

    • optimizesmart

      As long as i know it is true in case of UA too.

  • http://www.digitaldiscovery.com.pt/ Pedro Menezes Pereira

    Great great post m8y :)

    One quick question.

    How do I implement an event tracking in a wordpress page to monitorize a click in a button?

    In have this page http://www.digitaldiscovery.com.pt/contacto/ and I want to see in GA everytime a person clicks in “Enviar” with means “Send”

    I was checking the entire post and I´m still with doubts :)

    Thanks in advance!

    My regards,

    Pedro Menezes Pereira

  • Marc K – Engagement Specialist

    We haven’t tracked events in the past but want to going forward. Now that I’ve upgraded our account to Universal Analytics do I need to change anything or add anything to the javascript in the page headers to track events or is this built in to the new analytics.js, so that now all I need to do is add the extra code to the href statements in the body of our pages?

  • Marc K – Engagement Specialist

    What do the “10″‘s in the onClick statements in these two examples refer to?

    Examples:

    To track the clicks on the link ‘Download SEO Beginners Guide’, you would place the event tracking code like this:

    Download SEO Beginners Guide

    To track the clicks on the link ‘Download Social Media Guide’, you would place the event tracking code like this:

    Download Social Media Guide

    Read more: http://www.optimizesmart.com/event-tracking-guide-google-analytics-simplified-version/#ixzz32ZtIvb82

  • nikhil

    Hi Himanshu, thanks for the article :) I have a question regarding number of events under one category. I’m seeing that in event flow report after 11th Event in the flow GA starts grouping events. Is it because of any limit that GA has setup? if yes how can i handle cases where i cant reduce the number of event but still want to see each event separately.