Amazon Mobile Analytics: Try Amazon Pinpoint


Amazon Mobile Analytics is now part of a more fully featured service called Amazon Pinpoint. Using Amazon Pinpoint, you can gather and view customized metrics, as in Amazon Mobile Analytics, and then create a campaign to respond to your user's behavior via push notification based on the data you receive.

Existing Amazon Mobile Analytics for your mobile apps are automatically ported to the Amazon Pinpoint console and will continue to function as expected.

Using Amazon Mobile Analytics, you can track customer behaviors, aggregate metrics, generate data visualizations, and identify meaningful patterns. The AWS SDK for iOS provides integration with the Amazon Mobile Analytics service. For information about AWS service region availability or Mobile Analytics region availability, see AWS Service Region Availability.

What is Amazon Mobile Analytics?#

Amazon Mobile Analytics lets you collect, visualize, and understand app usage for your iOS, Android, FireOS, Windows Phone, Blackberry mobile apps as well as desktop and web apps running on Windows, OS X, and Linux. Reports are available for metrics on active users, sessions, retention, in-app revenue, and custom events, and can be filtered by platform and date range. Amazon Mobile Analytics is built to scale with your business and can collect and process billions of events from many millions of endpoints.

To learn more about Mobile Analytics, see the Amazon Mobile Analytics User Guide

IAM Policy for Amazon Mobile Analytics#

To use Amazon Mobile Analytics, AWS users must have the correct permissions. The following IAM policy allows the user to submit events to Amazon Mobile Analytics.

    "Statement": [{
        "Effect": "Allow",
        "Action": "mobileanalytics:PutEvents",
        "Resource": "*"

This policy should be assigned to roles associated with the Amazon Cognito identity pool for your app. The policy allows clients to record events with the Mobile Analytics service. Amazon Cognito will set this policy for you, if you let it create new roles. Other policies are required to allow IAM users to view reports.

You can set permissions at To learn more about IAM policies, see Using IAM.

Integrating Amazon Mobile Analytics#

The sections below explain how to integrate Amazon Mobile Analytics with your app.

Create an App in the Amazon Mobile Analytics Console#

Go to the Amazon Mobile Analytics console and create an app. Note the appId value, as you'll need it later.

To learn more about creating new apps in the console, see Managing Apps in the Amazon Mobile Analytics User Guide.

Integrate the SDK into Your App#

If you haven't already done so, download the SDK for iOS, unzip it, and include it in your application as described at Set Up the SDK for iOS. The instructions direct you to import the headers for the services you'll be using.

#import <AWSMobileAnalytics/AWSMobileAnalytics.h>

Initialize an AWSMobileAnalytics client. In doing so, you'll need to provide the appId value that you generated in the Amazon Mobile Analytics console. The appId is used to group your data in the Amazon Mobile Analytics console.

AWSMobileAnalyticsConfiguration *analyticsConfiguration = [[AWSMobileAnalyticsConfiguration alloc] init];
[analyticsConfiguration setServiceConfiguration:serviceConfiguration];
AWSMobileAnalytics *analytics = [AWSMobileAnalytics mobileAnalyticsForAppId:@"yourAppId" configuration: analyticsConfiguration];

where "yourAppId" is the appId value from the Amazon Mobile Analytics console.

Add Monetization Events#

The SDK for iOS provides the AWSMobileAnalyticsAppleMonetizationEventBuilder class, which helps you build monetization events to track purchases from Apple’s IAP Framework.

To learn more about monetization events, see:

Record Custom Events#

To record custom events, we first need to get the event client from the AWSMobileAnalytics instance.

id<AWSMobileAnalyticsEventClient> eventClient = analytics.eventClient;

For this example, let's say your app is a game, and you want to record an event when a user completes a level. Create a "LevelComplete" event.

id<AWSMobileAnalyticsEvent> levelEvent = [eventClient createEventWithEventType:@"LevelComplete"];

Note that custom events can't start with an underscore (_), or they'll be filtered out.

Add attributes and metrics to the event in key-value pairs.

[levelEvent addAttribute:@"Upper Dungeon" forKey:@"LevelName"];
[levelEvent addAttribute:@"Moderately difficult" forKey:@"Difficulty"];
[levelEvent addMetric:@1763 forKey:@"TimeToComplete"];

Record the event.

[eventClient recordEvent:levelEvent];

Events are submitted automatically when the user goes into the background. However, if you want to submit events manually, you can do so with the submitEvents method.

[eventClient submitEvents];

If you don't call submitEvents, events will automatically be submitted at periodic intervals.

To learn more about custom events, see: