diff --git a/CHANGELOG.md b/CHANGELOG.md index 7285156..ab42f72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # ember-cli-google-analytics Changelog +### Master + +* [BUGFIX] Mixin would not fire unless the `googleAnalytics.tracker` configuration option was explicitly set. It now defaults to `analytics.js` when no value is set. +* [BUGFIX] Mixin used hard-coded `ga` global variable when using the analytics.js tracker. It will now use the value set in the `googleAnalytics.globalVariable` configuration option, or `ga` if no value is set. + ### v1.3.0 * Added a mixin that can be included in the applications Router that will trigger the Google Analytics pageview when transitioning between routes. diff --git a/app/mixins/google-pageview.js b/app/mixins/google-pageview.js index 17b95df..a2192f6 100644 --- a/app/mixins/google-pageview.js +++ b/app/mixins/google-pageview.js @@ -4,10 +4,12 @@ import ENV from '../config/environment'; export default Ember.Mixin.create({ pageviewToGA: function() { if (Ember.get(ENV, 'googleAnalytics.webPropertyId') != null) { - var trackerType = Ember.get(ENV, 'googleAnalytics.tracker'); + var trackerType = Ember.getWithDefault(ENV, 'googleAnalytics.tracker', 'analytics.js'); if (trackerType === 'analytics.js') { - window.ga('send', 'pageview', { + var globalVariable = Ember.getWithDefault(ENV, 'googleAnalytics.globalVariable', 'ga'); + + window[globalVariable]('send', 'pageview', { 'page': this.get('url'), 'title': this.get('url') });