How to use cordova-plugin-google-analytics in controller.js?

Hi Ionic lovers!

I am trying to use this plugin: right now and it is working fine in my app.js. In app.js, I have the following code:

.run(function($ionicPlatform, $rootScope, $ionicConfig, $timeout) {

  $ionicPlatform.on("deviceready", function(){

if(window.cordova && window.cordova.plugins.Keyboard) {
}'XXXXXX');'App Init');

However, when I try to use the same code in one of my view controllers, I get the “Cannot read property ‘analytics’ of undefined” error. I have also tried using $cordovaGoogleAnalytics and passing that into my controller as a dependency as well but the same thing happens. Any thoughts?

EDIT: Turned out using works fine in other controllers. I had to wrap it in a ionicView.enter scope. GA also updates about one day late for a new trackView so I should’ve been a bit more patient!