jQuery.analytics is an Google Analytics jQuery plugin that is easy to implement and allows for declarative tagging to track events and pageviews.
- Track Page Views
- Track Click Events with easy declartive syntax
Download the production version or the development version.
-
Include jQuery version 1.4.3 or later
-
Include jquery.analytics.js script
-
Initialize the plugin
$(document).ready() { $(document).analytics(); };
-
Add declarative data attributes to things you want to track events on
<button data-track='{ "category" : "search", "action" : "button", "label" : "Search" }'>Search</button>
I recommend the excellent Google Analytics Debugger Chrome extension to test what gets tracked via Google Analytics.
jQuery version 1.4.3 - see data() support
As of 2/9/14 this jQuery plugin supports both versions of Google Analytics
analytics.js
Supports Google's latest version of Universal Analytics script called analytics.js which uses the "ga" object.
ga.js
This is the older version of Google Analytics tracking that uses the asynchronous syntax.
(Nothing yet)