Skip to content

Commit

Permalink
Update the mixin to not use hard-coded ga and work if no tracker co…
Browse files Browse the repository at this point in the history
…nfig option is set
  • Loading branch information
Peter Grippi committed Feb 7, 2015
1 parent 2ce5cdb commit 667eb3c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
6 changes: 4 additions & 2 deletions app/mixins/google-pageview.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
});
Expand Down

0 comments on commit 667eb3c

Please sign in to comment.