This project is no longer maintained.
A jQuery plugin to capture DOM events and send data regarding the event to Google Analytics as a tracked event.
- jQuery (tested with ~1.11.0)
- Google Analytics Web Tracking - analytics.js
bower install ga-event-track
- Add the dist folder's jquery.ga-event-track.min.js file to your website
<script src="jquery.ga-event-track.min.js"></script>- Forms: On the body element, add a "ga-track-forms" class attribute to any webpage with forms you wish to track.
<body class="ga-track-forms">
...
<form name="mncatplus"...>
<input name="request" type="text"/>
<input type="image" src="../path"/>
<input type="radio" name="type" value="keyword"/>
<input type="radio" name="type" value="title"/>
<input type="radio" name="type" value="author"/>
</form>- When the form's onsubmit event is triggered, you'll capture:
| Event Category | Event Action | Event Label |
|---|---|---|
| Form | Submit | { "location":{ "hostname":"www.lib.umn.edu", "pathname":"/" }, "name":"mncat-discovery", "inputs":{ "submit":"", "phrase":"beer" }, "media":"large", "date":1409081954817 } |
- Links: On the body element, add a "ga-track-links" class attribute if you wish to track links.
<body class="ga-track-links">
...
</body>- When a link's onclick event is triggered, you'll capture:
| Event Category | Event Action | Event Label |
|---|---|---|
| Links | Click | { "location":{ "hostname":"drupal.dev", "pathname":"/" }, "media":"large", "mouse":{ "pageX":200, "pageY":400 }, "href":"researchsupport", "text":"Researcher", "parents":"main|featured-items|researcher-support", "date":1409082445329 } |
- Scroll Depth: On the body element, add a "ga-track-scroll" class attribute if you wish to capture scroll depth.
<body class="ga-track-scroll">
...
</body>- When a user scrolls down the page, you'll collect scroll depth events.
Install the project's dependencies
npm installRun the test suite
grunt testuglifyjs src/* --source-map "dist/jquery.ga-event-track.min.js.map" -o "dist/jquery.ga-event-track.min.js"Eric Larson
Copyright (c) 2013-2016 Regents of the University of Minnesota - The MIT License (MIT)

