Google Analytics Views

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.trackView('Screen Title');
		} else {
			alert("Analytics could not be loaded.");
	} catch(e) {

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,

1 Like

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

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.

1 Like

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!

1 Like

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

1 Like

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

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’);

Hey, I’m not familiar with adding custom dimensions, but the docs say it should be like this'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:

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

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


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.


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?