Google Product Forums

Re: Event Tracking

PPC_Guru Sep 7, 2009 2:20 PM
Posted in group: Google Analytics

Categories: The Google Analytics Coffee Shop :

I have posted this message to GA team:

Event Tracking documentation page is unclear due to these 4 common errors reading this page:
http://code.google.com/apis/analytics/docs/tracking/eventTrackerGuide.html#Values

1. optional_value is an integer also-known-as "a number with 0 decimal places". This should be on BIG writing on the help page.

2. Because optional_value is a integer it does NOT need to be surrounded by quotes.

_trackEvent('category', 'action', 'optional_label', optional_value)

3. Comma, single or double quotations need to be escaped e.g.
word\,with\,comma
word\'with\'singlequote
word\"with\"doublequote
 
4. When using eventTracking & a virtual pageview on the same function; double quotes need to be changed to single quotes, so that the function is correctly encapsulated :

_trackEvent("category", "action", "optional_label", optional_value)
to
onclick="_trackEvent('category', 'action', 'optional_label', optional_value);"

Or here is a live example:
<a href="http://www.yourdomain.com/page.htm" onclick="pageTracker._trackEvent('category', 'action', 'optional_label', optional_value); pageTracker._trackPageview('/page.htm'); ">Link which triggers event & virual pageview</a>

Cheers

Phil.