Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Simple Backbone and Google Analytics Integration
branch: gh-pages

This branch is even with aterris:gh-pages

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
examples
spec
LICENSE
README.md
Rakefile
backbone.analytics.coffee
backbone.analytics.js
backbone.analytics.min.js
index.html

README.md

Backbone Analytics

A small object to manage the integration of google analytics into a backbone application. It is meant to be simple and implementation agnostic. Depends on Underscore.js and Backbone.js. For more detailed documentation see the docs

Example

 <script src="/js/underscore.js"></script>
 <script src="/js/backbone.js"></script>
 <script src="/js/backbone.analytics.js"></script>
 <script>
   window.App = window.App || {};
   window.App.ga = new Backbone.Analytics({code: 'UA-12345678-9'});
 </script>

Usage

This object is meant to be simple and flexible so you can use it however works best for your needs and implementation. I prefer to extend the object and use it to write methods that contain my specific analytics integrations. However, you can also use it as is.

Option Defaults

  • setAccount: true
  • initialPageview: true
  • trackNavigate: true
  • loadScript: true
  • debug: false

Syntactic Sugar

Backbone.Analytics provides a few convience methods that wrap around common google analytics objects and interactions including queue, push, setAccount, trackPageview, trackEvent, trackSocial, and setCustomVar

Debug Mode

Enabling debug mode will include the debug version of the google analytics script instead of the standard script. This will log debug information to the console. Enable debug mode by passing debug: true

Extending Backbone.Analytics

Extending Backbone.Analytics can help you manage and maintain your domain specific analytics interactions in a single location.

Something went wrong with that request. Please try again.