Last active
August 29, 2015 14:15
-
-
Save pk/5552d00f36e624075302 to your computer and use it in GitHub Desktop.
core/analytics.service.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular | |
.module("core.analytics", []) | |
.service("Analytics", function($rootScope, $state){ | |
this.handle = null; | |
this.setup = function(handle, trackerID){ | |
if (!handle) { | |
console.log("Analytics: Unable to initialize plugin!"); | |
return false; | |
} | |
// Configuraiton | |
this.handle = handle; | |
this.handle.debugMode(); | |
this.handle.startTrackerWithId("UA-59700725-1"); | |
console.log("Analytics: Did setup analytics..."); | |
// Observe view enter events and track current state | |
$rootScope.$on("$ionicView.enter", function(event){ | |
this.handle.trackView($state.$current.name); | |
console.log("Analytics: tracking " + $state.$current.name); | |
}); | |
return true; | |
}; | |
this.setUser = function(userID){ | |
if (!this.handle) return; | |
this.handle.setUserId(userID); | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment