Try Analytics for iOS

Use our iOS sample app to see how Analytics works, or add Analytics to your existing app.

To use this sample, make sure you have Xcode and CocoaPods.

Get the project

Start with the sample using the following command from a terminal:

$ pod try Google

Select the option for AnalyticsExample.xcodeproj from the prompt.

Run the sample

Now you're ready to build the sample and run it from Xcode.

Select the AnalyticsExample target. Then start the application on a device or in the iOS simulator by clicking the run button for the workspace.

Look for log messages in the Xcode Console that record Analytics activity. You can record activity on different screens by selecting different patterns in the tab bar at the bottom of the screen.

2015-04-07 14:20:25.166 TestApp[72212:2336930] INFO: GoogleAnalytics 3.10 -[GAIBatchingDispatcher didSendHits:] (GAIBatchingDispatcher.m:219): 1 hit(s) sent

Go to Analytics and select the Analytics account you registered the app with. If you're unsure, look for the Analytics tracking ID in the GoogleService-Info.plist file you added to your project earlier. Copy that ID to the Analytics account search in the report drop-down. Select the Real-Time > Overview report for your property.

Now you can view your app's activity in real-time! The Screen Views graph displays screen views, and you can trigger more by clicking tabs in the application. The real-time report displays activity as it reaches the servers, so you can use this to quickly test your setup.

How it works

Like web tracking, Analytics for mobile collects user activity to your app with an Analytics beacon that sends data to the Analytics servers. Each unique view in your app corresponds to an Analytics screen view. The report aggregates all interaction data within the last 30 minutes.

This samples uses the GAITracker interface to retrieve the screen name and send it as a screen view to the Analytics account associated with your app.

Note: Unlike web tracking, the Analytics Mobile SDK uploads activity signals in batches, both to conserve the device's radio and to handle periods of offline user activity.

id<GAITracker> tracker = [GAI sharedInstance].defaultTracker;
[tracker set:kGAIScreenName value:name];
[tracker send:[[GAIDictionaryBuilder createScreenView] build]];

Next steps

Learn how to use Google Analytics to collect more app usage info, such as taps to a UI element with Event tracking, or Google Play Campaign activity with Campaign tracking.

Add Analytics to your app

Did you have a good experience? Run into trouble? Let us know!