Event Tracking Blues
You code for hours but it doesn't work. Then you read the documentation which turns out to be poor. The question you posted in the forum is left unanswered for many weeks. Situations like these can happen to any Web Developer like me and is very frustating. I had such one in the previous weeks regarding Google Analytics' Event Tracking.
_trackEvent(category, action, optional_label, optional_value)
For example if you want to append the page performance of the contact site for custom reports:
_trackEvent('Page performance', '/contact/', 'ms', 534)
Whereas in this example the optional value 534 is generated on the server side. In PHP you can measure that by calling microtime() at the beginning and end of script execution.
The mistakes I made were:
- Surrounding this fourth optional parameter with semicolons like '534'
- Trying with a float number like 1.23 (for seconds)
Google Analytics never threw an error. I tried to debug, to check in Firebug console and with many different parameters until a mate told me to use integer instead. That's true, the documentation says that this fourth parameter must be an integer.
"Hooray!" - Finally I knew why it didn't work and smiled. All I had to do is to remove the semicolons and to change that floating number to an integer by using milliseconds instead of seconds. If Google Analytics' script had thrown an error or just anything, it would have saved me from wasting many hours ...