mirror of
https://github.com/correl/melpa.git
synced 2024-12-22 19:17:27 +00:00
Log page views to Google Analytics from Angular
This commit is contained in:
parent
b5659b4c7b
commit
84f3f9c49e
2 changed files with 9 additions and 2 deletions
|
@ -62,7 +62,6 @@
|
|||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-39278673-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
|
|
|
@ -143,11 +143,19 @@
|
|||
});
|
||||
});
|
||||
|
||||
app.controller('AppCtrl', function($scope, $rootScope, $route) {
|
||||
app.controller('AppCtrl', function($scope, $rootScope, $route, $window) {
|
||||
$scope.hideSplash = false;
|
||||
$rootScope.$on("$routeChangeSuccess", function() {
|
||||
$scope.hideSplash = ($route.current.controller != 'PackageListCtrl');
|
||||
});
|
||||
$rootScope.$on("$locationChangeSuccess", function(e, newURL, oldURL) {
|
||||
if (newURL && (newURL.$$route||newURL).redirectTo) return;
|
||||
if ($window._gaq && newURL != (oldURL + "#/")) {
|
||||
var l = $window.location;
|
||||
var path = l.pathname + l.hash + l.search;
|
||||
$window._gaq.push (["_trackPageview", path ]);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Reference in a new issue