analytics.js 577 B

123456789101112131415161718192021222324252627
  1. define([
  2. 'angular',
  3. '../core_module',
  4. ],
  5. function(angular, coreModule) {
  6. 'use strict';
  7. coreModule.default.service('googleAnalyticsSrv', function($rootScope, $location) {
  8. var first = true;
  9. this.init = function() {
  10. $rootScope.$on('$viewContentLoaded', function() {
  11. // skip first
  12. if (first) {
  13. first = false;
  14. return;
  15. }
  16. window.ga('send', 'pageview', { page: $location.url() });
  17. });
  18. };
  19. }).run(function(googleAnalyticsSrv) {
  20. if (window.ga) {
  21. googleAnalyticsSrv.init();
  22. }
  23. });
  24. });