Event Tracking code for clicks

Discussion in 'Google Analytics' started by TDR69, Mar 14, 2013.

  1. #1
    Hi,
    We are driving traffic to one of our webpages which is written in HTML.
    When the visitor visits the landing page, there are 4 in-built tabs/categories which expands within the same page upon clicking. e.g. FAQ, About, Sign up dates etc. There is no separate URL for these tabs.

    Obviously, Analytics is not showing me how many visitors are clicking on which tab.
    Can someone clearly tell me;
    1. The code I should use to track the clicks on these 4 tabs?
    2. Do I need only 1 code to track 4 categories?
    3. Since in all 4 categories I want to track 'Clicks' as 'actions', do I need to rename them differently because event tracking combines metrics for the same action name across different categories?
    Please help!
     
    TDR69, Mar 14, 2013 IP
  2. Spixels

    Spixels Member

    Messages:
    32
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    48
    #2
    Hey I'm not sure what HTML structure you're using for the categories but whatever tag it is you can put this code in: onclick="_gaq.push(['_trackEvent', 'category name', 'action name', 'action label']);"

    Now the only 2 parameters that are required are the first two, category and action so if you want to keep it simple you can have something like this in your div or li, or whatever tag you use:

    onclick="_gaq.push(['_trackEvent', 'Art Category', 'Expand']);"

    So you will need an onclick on each category.

    Hope this helps
     
    Spixels, Mar 21, 2013 IP
  3. ffb

    ffb Active Member

    Messages:
    79
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    75
    #3
    Some common things to check as well (almost everyone forgets to do this):

    - Check which version of GA you're using so that the event tracking code you're using is correct. If you're using the traditional GATC, then the code above doesn't work.

    - You'll also probably need to trigger a call to ga.js again, otherwise the code above doesn't do anything.

    ;)
     
    ffb, Mar 24, 2013 IP