Analytics jQuery Plugin 2.0 Supports Full Tracking API

Updated Google Analytics jQuery plugin to version 2.0 and it now is the only jQuery plugin that supports full tracking API of Google. Apart from enhanced loading of ga.js file, there is a lot more that users can now do with this plugin.

What’s new in version 2.0.0?

The plugin now loads Google Analytics pageTracker and dynamically binds to the pageTracker public API.

What this means is that now, you can access the entire Google Analytics tracking API using this plugin. All of pageTracker’s public API is also available to $.ga object.

For example, the pageTracker._trackEvent method can be called by $.ga.trackEvent. Also, pageTracker._trackPageView can be called using $.ga.trackPageView.

Every method from the public tracking API, has been mapped to the $.ga object after dropping the initial underscore. pageTracker._getVersion() is same as $.ga.getVersion(), pageTracker._setClientInfo() can be invoked by $.ga.setClientInfo().

What this also means that, the process of binding to the public API being dynamic, any update or modification made to ga.js will automatically reflect in this plugin.

And ah… it also reflects that this is the first jQuery Plugin that supports full tracker API in a much simpler way.

It allows users to execute a callback function after successful load of Google Analytics code.

This is useful for users who want a specific set of codes to be executed after the successful load of Google Analytics code. This can be done by passing a function to the second parameter of $.ga.load method.

Using this, you can shift all your custom tracking codes to a neat function in the page header. Furthermore, the first parameter passed to your function is the pageTracker object, you can use this just like the native Google Analytics API codes.

Deprecated the $ga.track() method.

This is the sad part of the story. Though I always strive never to change the API of my applications, yet due to implementation issues, I had to do so for this case.

$.ga.track is still accessible, but as $.ga.trackEvent and that too after the successful load of Google Analytics codes.