001221 001221 - 23 days ago 14
Javascript Question

Google Analytics Event Tracking code

I'm using Google Analytics, at the top level I can see who has come onto my site, however I cannot see track my event tracking for my social network buttons, I think I may have developed these wrong.

These events are not been tracked on my analytics account that I can see anyway if someone knows where they are kept that would be great.

But the code I've used is below as I'm not sure if I have implemented this correctly:

<a href="https://twitter.com/share?text=2009:%20Michael%20Jackson%20Dies&hashtags=DIGITL,MichaelJackson" target="_blank" onClick="_gaq.push(['_trackEvent', 'Social Media', 'Twitter', 'Share 2009 Jackson',, false]);"><img src="images/twitter_icon.png" id="2009_michaeljackson_share_twitter" alt="Share on Twitter" title="Share on Twitter"></a>


If someone can advise if this is correct will be great!

Update



As per the answer below, I removed the double comma retested in the Events Overview section and no on click items have appeared...

Example of updated code:

<li><a href="#" onClick="_gaq.push(['_trackEvent', 'Social Media', 'Facebook', 'Share 2003', false]);"><img src="images/facebook_icon.png" id="2003_share_fb" alt="Share Icon for Twitter" title="Share on Facebook"></a></li>


I've even added them as a goal in Google Analytics but this doesn't seem to work either.

Any ideas?

Answer

If you are using the OLD GOOGLE ANALYTICS TRACKING BLOCK, then the below should work:

<li><a href="#" onclick="_gaq.push(['_trackEvent', 'Social Media', 'Facebook', 'Share 2003', false]);"><img src="images/facebook_icon.png" id="2003_share_fb" alt="Share Icon for Twitter" title="Share on Facebook"></a></li>

If you are using the NEW GOOGLE UNIVERSAL EVENT TRACKING code the below will work:

<li><a href="#" onclick="ga('send', 'event', 'Social Media', 'Facebook', 'Share 2003');"><img src="images/facebook_icon.png" id="2003_share_fb" alt="Share Icon for Twitter" title="Share on Facebook"></a></li>

To check whether the events are firing correctly VERY QUICKLY. Do the following;

1. Make sure you update the code on your site and make it live

2. Make sure your IP is not excluded or filtered out of the analytis profile

3. Login to your google analytics account

4. Go to Real-Time section on the left hand sidebar.

5. Click on Events

6. Go to your site and click on the link you added the event code to and then watch if that link shows up in the real-time -> events section.

Bounce Rate Discussion

About the bounce rate everyone is talking about. Usually when you add an event and someone clicks on it, then google analytics will assume that user interacted with your site and therefore provide a very low bounce rate for that page. If you don;t want the bounce rate to be affected on the page where the event is placed, then you can add the false at the end of the event. I would suggest you get the event tracking working, before trying to adjust the bounce rates :-)

Thank you,