An Aurelia plugin that adds Google Analytics page tracking to your application with just a small amount of configuration. Set it up once and forget about it.
This plugin was built based on this blog post.
- Install aurelia-google-analytics
jspm install aurelia-google-analytics
# or ...
npm install aurelia-google-analytics --save
- Use the plugin in your app's main.js:
export function configure(aurelia) {
aurelia.use.plugin('aurelia-google-analytics', config => {
config.init('<Your Tracker ID>');
config.attach({
logging: {
enabled: true // Set to `true` to have some log messages appear in the browser console.
},
pageTracking: {
enabled: true // Set to `false` to disable in non-production environments.
},
clickTracking: {
enabled: true // Set to `false` to disable in non-production environments.
}
});
aurelia.start().then(a => a.setRoot());
}
In order to use the click tracking feature, each HTML element you want to track must contain a data-analytics-category
and data-analytics-action
attribute. data-analytics-label
and data-analytics-value
are supported and optional.
Install dependencies
npm install
Then
gulp build
The result is 3 module formats separated by folder in dist/
.
- aurelia-dependency-injection
- aurelia-event-aggregator
- aurelia-logging
- aurelia-router implicit dependency because this plugin listens to the router:navigation:success event
Yes, please!