Google Analytics

Google Analytics Event Tracking for Universal Code

Google AnalyticsYou may not have realized that since Google Analytics made the switch to its Universal Analytics code you event tracking code has to change. The common error resulting from using classic analytics event tracking syntax with the new Universal Analytics code is:

Uncaught ReferenceError: _gaq is not defined

This is because the new code uses ‘ga’ instead of ‘_gaq’.

Also, the syntax of the call has changed. If you don’t update the syntax you may end up with this error:Uncaught syntax error”: Unexpected identifier

Uncaught syntax error”: Unexpected identifier

Here’s an example of what you use with classic analytics:
onClick=”_gaq.push([‘_trackEvent’, ‘Phone’, ‘Click’, ‘Click to Phone’]);”

What you should be using now looks more like this:
onClick=”ga(‘send’, ‘event’, ‘Phone’, ‘Click’, ‘Click to Phone’);”

Leave a Reply

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