A small plugin that enables Google Analytics tracking for your Sammy powered App.
Download sammy.googleanalytics.js and install it in your public javascripts directory. Include it in your document AFTER sammy.
Install Google Analytics to your site as you normally would. Be sure that the 'pageTracker' global variable exists.
Then, simply add the plugin to your Sammy App and it will automatically track all of your routes in Google Analytics. They will appear as page views to the route's path.
$.sammy(function() { with(this) {
use(Sammy.GoogleAnalytics)
...
}});
If you have routes that you do not want to track, simply call "noTrack" within the route.
$.sammy(function() { with(this) {
use(Sammy.GoogleAnalytics)
get('#/dont/track/me', function() {
this.noTrack(); // This route will not be tracked
});
}});
http://britg.github.com/sammy-google-analytics
Sammy http://code.quirkey.com/sammy
Sammy requires jQuery >= 1.3.2 Get it from: http://jquery.com
- Follow @sammy_js
- Join the mailing list
- Chat with us in #sammy
Sammy is covered by the MIT License. See LICENSE for more information.
Sammy includes code originally created by John Resig (Class implementation) and Greg Borenstien (srender).