My google analytics in my ionic app doesn't report any active app user

Hey guys, I’ve just integrated google analytics using the instruction at https://blog.nraboy.com/2014/06/using-google-analytics-ionicframework/, at first after i deployed the app, i found no new user, so i waited for about half a day. And when I check my analytics account, I got new users who used desktop OS not smartphone OS. I find this very weird because the tracking ID should restricted to me and I shoud have one new user because only I have the app. Can someone exaplain what’s happening ? (Note : I use mobile app preference in google analytics)

Are you sure you have it set up as a mobile app, and that you’re using the correct tracking ID? Also, are you telling it to track anything, such as:

analytics.trackView('Screen Title')

I’ve noticed that that plugin will only track analytics if the app is built, so it shouldn’t report any desktop statistics. It also won’t show real time data for about a day after you’ve created the tracking number.

If you still don’t have it working, maybe this topic will help:

@brandyshea I’m so sorry for my late reply. With what should I replace ‘Screen Title’ ? html title or state ? I have read https://github.com/danwilson/google-analytics-plugin but I ended up not completely understand it. Could you help me understand it ?

‘Screen title’ is whatever you want to use to track it. For example I have a screen used to find locations and I pass “Find Location” for the screen title (view to track). This is whatever makes sense to you for tracking.

Thx for the info @brandyshea, I’ve tried it again and to no avail, maybe you could check my code if that’s not bothering. Here’s my code :

.controller('homeController', function($scope,$http) {
    GetMainPage();
        function GetMainPage() {
            $http.get("http://xxxxx").
                success ( function(data) {
                    $scope.MainNews = data;
                })
            }
                
            if(typeof analytics !== 'undefined') { analytics.trackView("homeController"); }    
        }) 


.run(function($ionicPlatform, $ionicPopup) {
    $ionicPlatform.ready(function() {
        console.log(typeof analytics);
        if(typeof analytics !== 'undefined') {
            analytics.startTrackerWithId("UA-xxxx");
        } else {
            console.log("Google Analytics Unavailable");
            alert("Google Analytics Unavailable");
        }
    });
}); 

When i tested it in my android device, the alert didn’t show up which i presume that the plugin is working. But it doesn’t report anything.

I’m in deep, because no Android, and my country doesn’t show up which is Indonesia.

Add a trackView right after the start tracker id just to see if there is something happening with the controller. Make sure there are no errors in logcat. When you are using the app look for it in Real-Time.

Also, try removing the quotes from undefined, this seems to have helped someone: https://blog.nraboy.com/2014/06/using-google-analytics-ionicframework/#comment-1925242389

OMG, Thx a lot @brandyshea, now it works, n tracking my device. God bless you.

1 Like