in aurelia ~ read.

Aurelia - Plugin for Google Analytics

I needed to track page views for the project I'm working on so I created a plugin for Aurelia called aurelia-google-analytics. It's really simple to use and only requires 3 lines of configuration...yes, that's it! It only provides tracking for page views at the moment.

To install just use jspm like so:
jspm install aurelia-google-analytics

Then do the following to configure it in your Aurelia app:

// main.js

export function configure(aurelia) {  
        .plugin('aurelia-google-analytics', config => {
            config.enableTracking(true); // Set to `false` to disable in non-production environments.
            config.enableLogging(false); // Set to `true` to have some log messages appear in the browser console.
            config.init('<your GA Tracking ID here>', 'ga');

    aurelia.start().then(a => a.setRoot());

That's it! As your users browse your site their pages will be automatically tracked. In case you run into any problems, please file an issue here. Pull Requests are very much welcome as well!

comments powered by Disqus