Google Analytics Views


#1

Hello everyone,

I’m trying to get Google Analytics to work on my app. I’m using Dan Wilson’s plugin:

So far I have:

$ionicPlatform.ready(function() {
	try {
		if(typeof analytics !== 'undefined'){
			analytics.startTrackerWithId('XXXXXXXXXX');
			analytics.trackView('Screen Title');
		} else {
			alert("Analytics could not be loaded.");
		}
	} catch(e) {
		alert(e.message);
	}
}

I’ve put the correct ID there, but I’m not sure what to do with the trackView.
How does it work? Should there be one per app? Or per controller that I want tracked?
What should the value be? How does it link to Google Analytics?

I’d really appreciate any help with this.

Many thanks,
Ady


#2

Hi Ady,
Did you find any solution ? I have the same issue.
Thank you.


#3

I use the trackView per view. So in each controller I pass the name of the page (you decide what makes sense for you). The way it links to Google Analytics is by showing the screen name based on the value you passed. For example this is what I have in the controller for my search schedules page:

$scope.$on('$ionicView.beforeEnter', function() {
    analytics.trackView('Search Schedules');
});

Then, in Google Analytics you can see when a user accesses the screen in Real Time or in the App Overview (for past sessions).

You can also use it to set up goals, in our app we set up a funnel to see when a user gets to the final purchase screen.

Note: you need to have your code deployed as a mobile app in order for this to work. It will not work when using the browser for testing.

Which issue are you running into? This topic has some more information on analytic errors.


#4

I did exactly how Brandy showed, and it worked fine. I was just asking because, as the analytical data takes a while to appear, I wanted to make sure I was understanding and implementing it correctly.

If you’ve waited for a few days and still nothing appears on Google Analytics, then unfortunately I’m not sure where you’ve gone wrong. Check Brandy’s post, it should be able to help.

Thanks for the replies!


#5

Hi, many thanks for your replies. That works :wink:


#6

Careful I think data are not showing immediatly in the real time analytics, mine takes up to 10 minutes to show …


#7

Hi @brandyshea, I was wondering what I should do in order to track a view adding a custom dimension (e.g., gender). Would be something like this:?

$scope.$on(’$ionicView.beforeEnter’, function() {
analytics.addCustomDimension(‘Gender’, ‘female’);
analytics.trackView(‘Search Schedules’);
});


#8

Hey, I’m not familiar with adding custom dimensions, but the docs say it should be like this window.analytics.addCustomDimension('Key', 'Value', success, error). Maybe you need to pass a success and error function?

According to this post the key is actually the index of the custom dimension: https://github.com/danwilson/google-analytics-plugin/issues/71


#9

Thanks for the link, I’ll have a try!


#10

Can anyone tell me how to send the os version and device info to the Google analytics


#11

Hello,

I’m trying to use Analytics in my Ionic app but something is wrong… I saw your printscreen of google analytics and saw that you created in GA an App and not an website.

Is it right?

kind regards.


#12

Hi,

Did you finally figure it out? I can see my connection in real-time, but somehow can’t get tracking data to show up. Do I need to create a mobile app as opposed to a website?