Skip to content

Commit

Permalink
add universal analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
weblancaster committed Sep 8, 2015
1 parent 91f8147 commit 118867e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 12 deletions.
12 changes: 0 additions & 12 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -247,17 +247,5 @@ <h4 id="playerUser" class="player_user"></h4>
<!-- filters -->
<script src="public/js/common/roundFilter.js"></script>


<!-- GA / DO NOT CHANGE OR USE THIS CODE -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-67310953-1', 'auto');
ga('send', 'pageview');
</script>

</body>
</html>
12 changes: 12 additions & 0 deletions app/public/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ app.config(function ($stateProvider, $urlRouterProvider, hotkeysProvider) {
});

app.run(function($rootScope, $log, SCapiService, hotkeys) {

//start GA
window.visitor.pageview("/").send();

// toastr config override
toastr.options.positionClass = 'toast-bottom-right';
toastr.options.timeOut = 4000;
Expand All @@ -64,6 +68,14 @@ app.run(function($rootScope, $log, SCapiService, hotkeys) {
$rootScope.$on('$stateChangeSuccess', function(event, toState, toParams, fromState, fromParams){
$rootScope.oldView = fromState.name;
$rootScope.currentView = toState.name;

// set GA page/view
if ( toState.name === "" ) {
window.visitor.pageview("/").send();
} else {
window.visitor.pageview(toState.name).send();
}

});

// shortcut to open devtools
Expand Down
6 changes: 6 additions & 0 deletions app/public/js/system/core.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use strict";

var ua = require('universal-analytics');
var gui = require('nw.gui'),
uiFrame = {},
OAuthVerification = {},
Expand All @@ -8,6 +9,11 @@ var gui = require('nw.gui'),
appSystem = {},
appUser = {};

// GA / DO NOT CHANGE OR USE THIS CODE
// setup GA
window.visitor = ua('UA-67310953-1');
// END

/**
* Responsible to verify if user was authenticated
*/
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@
"grunt-contrib-watch": "^0.6.1",
"grunt-node-webkit-builder": "^1.0.2",
"grunt-sass": "^0.18.1"
},
"dependencies": {
"universal-analytics": "^0.3.9"
}
}

0 comments on commit 118867e

Please sign in to comment.