adding analytics to Chaplin.js application
Adding Google Analytics/Piwik/whatever to your front-end application can sometimes be tricky, with Chaplin.js it's a breeze though:
# The application object.
module.exports = class Application extends Chaplin.Application
initialize: ->
@subscribeEvent '!router:route', @analyticsHooks
super
analyticsHooks: (route, params)->
console.group("Analytics")
console.log route
console.log params
console.groupEnd("Analytics")
This adds a subscriber on the application level for all route events and passes the route and route params to your Application#analyticsHooks.
Written by Benjamin
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Coffeescript
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#