Skip to content

Integrating Google Analytics

John J Czaplewski edited this page Oct 7, 2013 · 2 revisions

By default, Google Analytics will use your current URI, and will only be triggered upon page load. This isn't ideal for applications that provide client-side routing with libraries like PathJS. To update your Google Analytics when different actions are hit via PathJS, you can use the following code:

// Define our update method.
function updateAnalytics(){   
    ga('send', 'pageview', document.location.href);
}

Path.map("#/users/:id").enter(updateAnalytics).to(function(){
    // Code here
});
Clone this wiki locally