• Home
  • Google Analytics
    • Customizations
    • For Ecommerce
  • Speaking
  • About
    • About Me
    • Contact Me
    • Disclaimer and Privacy Policy

Analytics Talk

Digital Analytics for Business

You are here: Home / Event Tracking / Event Tracking Pt. 2: Implementations

Event Tracking Pt. 2: Implementations

Posted: October 16, 2007 14 Comments

In this post I’m going to discuss how to implement event tracking in Google Analytics. If you have not read part 1, I strongly recommend you do so because I reference Part one extensively. When we implement event tracking we add code that creates the data model we defined in Part 1. We’re going to continue our example of tracking an event in Google Maps. We want to find out how which map view people use most.

The Data Model

If you remember part 1, I created a data model for our event data. This will help us answer our business question and it will help use create the code.

Tag Your Pages

I know this seems simple, but the first step is to make sure your pages are tagged with the GA tracking code. Remember, this only works with the new ga.js tracking code.




Creating The Object

The first thing we need to do is create the object that we want to analyze. To create a new object we use a method name _createEventTracker(). We pass this method a value and that value is the name of the object we defined in the data model. Our object is called ‘Map’ so let’s use ‘Map’ in the name:

var mapEventTracker  = pageTracker._createEventTracker('Map');

When we look at the reporting interface we will see ‘Map’ in the Objects report. Pretty straight forward, huh?

This code must appear after your GA page tag. The reason is that the _createEvent Tracker() method is attached to the pageTracker object. In this example, I’m going to place it in the same block as the regular tracking code:




Tracking the Action

Now that we have an object, how do we track an action associated with that object? We add JavaScript to our page code when the action takes place. So, with our Maps example, we would add some code when the visitor clicks on the button to change the Map view type. Here’s how that code might look:

onClick="mapEventTracker._trackEvent('Change Map View',

<label> and <value> should be replaced with one of the labels we identified in our data mode:

Map 5
Satellite 10
Hybrid 15
Street Level 20

What happens when a visitor clicks on a map button is that the code sends the action, label and value to GA and associates it with the map action we defined above. Now you can see how our data model really drives the implementation.

Tracking Multiple Objects

Ok, so here is something that’s pretty cool. Let’s say the map team wants to add two different maps to a single page. We can track both of them using the same map object. We would then differentiate what the visitor does using different labels. The actions would remain the same for both objects, but we’d have different labels.

A Final Note

I’d like to say that every implementation for event tracking can be different. It really depends on the business questions you need to answer and the structure of your pages. I think this post does a very good job of covering the basics, but your specific implementation will probably be a bit different… Unless you’re Google Maps. :)

As we’ll see in the next post, the new Event reports provide a logical structure for analyzing event data.

Filed Under: Event Tracking, Tracking Tagged With: Event Tracking, features, google-analytics, setup

Comments

  1. Anders Møller says

    October 17, 2007 at 9:22 am

    This is so cool, i cant wait to play with this, It opening so many possibility to implement cool stuff.

    Reply
  2. Justin says

    October 17, 2007 at 9:30 am

    Hi Anders,

    I agree! I’m really excited about the new features and the data we’ll be able to collect.

    Justin

    Reply
  3. Jahangir says

    October 28, 2007 at 3:01 am

    A doubt, in the tracking of the event object with the code that you gave “onClick=” mapEventTracker._trackEvent(’Change Map View’, <ACTION> ,<VALUE> );””

    What/why should be assigned here?? isn’t “value” automatically incremented for that particular Label when the event is executed??

    Thanks,
    Jahangir

    Reply
  4. Justin says

    October 29, 2007 at 10:26 am

    Hi Jahangir,

    The action and the value are not automatically incremented. In most cases, you will define those values. In some cases the value could be auto incremented, but it will be a value derived from something happening in the browser. For example, value could the the number of seconds it took for the page to render.

    User defined values would be specific for each action. Like clicking on the play button might be worth 100. It’s up to you.

    Once the reporting part of this feature is activated I’ll have more information for everyone.

    Thanks for reading and thanks for the question.

    Justin

    Justin

    Reply
  5. Gerard says

    November 19, 2007 at 5:37 pm

    Hi Justin,

    Event tracking seems much more powerfull than goals. Is there any possibilties it will replace goals in the near future ?
    Is there any limitation on event tracking (goals are limitied to maximum 4 in GA)?

    Reply
  6. Daniel Waisberg says

    November 26, 2007 at 1:31 am

    Hi Justin,

    wonderful series, really helpful. But I share with Jahangir a doubt on how to implement/define <ACTION> <VALUE> . Please let us know whenever you have more information about that…

    Thank you very much for sharing all that!

    Reply
  7. Justin Cutroni says

    November 26, 2007 at 9:26 am

    Gerard,

    Great observation. Based on what I’ve seen, events will be an effective way to circumvent the 4 goal limit in GA.

    Thanks for reading and thanks for the observation.

    Justin

    Reply
  8. Justin Cutroni says

    November 26, 2007 at 9:33 am

    Daniel,

    Event tracking is just a framework to track data. It’s so flexible that you can literally capture anything. However, the flexibility also makes the implementation difficult becuase you need to create the hierarchy of data before the implementation.

    When event tracking is rolled out to masses I’ll start writing more about it and provide some examples.

    Thanks for reading and thanks for the comment.

    Justin

    Reply
  9. Chad says

    November 29, 2007 at 3:10 pm

    Justin,

    Do you have any insight as to when event tracking will be rolled out to the masses?

    Thanks,

    Reply
  10. Daniel Waisberg says

    December 2, 2007 at 6:00 am

    Justin,

    please do a favor to the world: RELEASE A NEW VERSION OF YOUR PDF!

    You will make so many families happier: WA will arrive home earlier and play with their kids, enjoy their times with their husbands/wifes, have more time to spend on their hobbies, and so on. Christmas is coming…

    Thanks!

    Reply
  11. Justin Cutroni says

    December 3, 2007 at 12:14 am

    Chad,

    No news on when event tracking will launch, sorry!

    Daniel,

    I’m working as fast as I can to get the next version done! I’ll try to get you home for dinner as soon as I can. :)

    Justin

    Reply
  12. Avlok says

    May 9, 2008 at 12:31 pm

    Any word on the updated PDF? I loved your work on the first PDF but an updated one would make implementing the ga.js a lot easier :-)

    Reply
  13. Christina says

    July 2, 2008 at 1:14 am

    I do agree about the insights for event tracking. My question is that. Does this event tracking code imply for tracking a click in a static image?.

    Reply
  14. Justin Cutroni says

    July 2, 2008 at 7:56 am

    Hi Christina,

    You can use the event tracking code to track anything, including a click on a static image. The code for tracking a static image will be different than the code above because your data model for your events will be different than the data model I created for the example above.

    If you’re just getting started with event tracking check out the first post in the event tracking series. It talks about setting up a data model before adding any code.

    Thanks for the question,

    Justin

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

My Books

Google Analytics by Justin Cutroni
Learn More on Amazon.com

Performance Marketing co-authored by Justin Cutroni
Learn More on Amazon.com

Recent Posts

  • Understanding the Google Analytics Cohort Report
  • Using Offline and Online data to drive Google Analytics Remarketing
  • Understanding Cross Device Measurement and the User-ID
  • Universal Analytics: Now out of beta!
  • Advanced Content Tracking with Universal Analytics

Categories

  • About Google Analytics (25)
  • Analysis (52)
  • Analytics Strategy (3)
  • Campaign Tracking (14)
  • Ecommerce (8)
  • Event Tracking (10)
  • Remarketing (2)
  • Reporting (10)
  • Resources (7)
  • Tag Management (5)
  • Tips (25)
  • Tracking (52)
  • Uncategorized (64)
  • Universal Analytics (9)
  • Web Analytics (15)

Copyright © 2023 ·News Pro Theme · Genesis Framework by StudioPress · WordPress