Menu
Amazon Pinpoint
Developer Guide

Reporting Events

You can use the AWS Mobile SDK for iOS to report app usage data, or events, to Amazon Pinpoint. Report events to capture information such as app session times, users' purchasing behavior, sign-in attempts, or any custom event type that serves your needs.

After your app reports events, view app analytics in the Amazon Pinpoint console. The charts on the Analytics page provide metrics for many aspects of user behavior. For more information, see Chart Reference for Amazon Pinpoint Analytics in the Amazon Pinpoint User Guide.

To analyze and store your event data outside of Amazon Pinpoint, you can configure Amazon Pinpoint to stream the data to Amazon Kinesis. For more information, see Streaming Amazon Pinpoint Events to Kinesis.

Reporting Session Events

Session events indicate when and how often users open and close your app. The AWS Mobile SDK for iOS automatically records session events when your app goes into the foreground and background. This behavior is configurable, and you may choose to implement your own session handling.

After your app reports session events, use the Analytics page in the Amazon Pinpoint console to view charts for Sessions, Daily active endpoints, 7-day retention rate, and more.

Reporting Monetization Events

To track the revenue that is generated by your app and the number of items purchased by users, update your app code to report monetization events.

After your app reports monetization events, view revenue analytics in the Amazon Pinpoint console. On the Analytics page, the Revenue tab provides charts for Revenue, Paying users, Units sold, and more.

The following examples use the analyticsClient of the AWSPinpoint class to create, record, and submit a monetization event.

Objective-C

In the following example, the AWSMobileClient class is provided in the AWS Mobile Hub sample code to reference the Amazon Pinpoint object.

Copy
AWSPinpointEvent *event = _pinpoint.analyticsClient createVirtualMonetizationEventWithProductId:@"PRODUCT_ID" withItemPrice:1.00 withQuantity:1 withCurrency:@"USD"]; [[AWSMobileClient sharedInstance].pinpoint.analyticsClient recordEvent:event]; [[AWSMobileClient sharedInstance].pinpoint.analyticsClient submitEvents];

Swift

Copy
let pinpointAnalyticsClient = pinpoint!.analyticsClient let event = pinpoint!.analyticsClient.createVirtualMonetizationEventWithProductId("PRODUCT_ID", withItemPrice: 1.00, withQuantity: 1, withCurrency: "USD") pinpointAnalyticsClient.recordEvent(event) pinpointAnalyticsClient.submitEvents()

Reporting Authentication Events

To learn how frequently users authenticate with your app, update your app code so that Amazon Pinpoint receives the following standard event types for authentication:

  • _userauth.sign_in

  • _userauth.sign_up

  • _userauth.auth_fail

After Amazon Pinpoint receives these event types, use the Analytics page in the Amazon Pinpoint console to view charts for Sign-ins, Sign-ups, and Authentication failures.

You can report authentication events by doing either of the following:

  • Managing user sign-up and sign-in with Amazon Cognito user pools.

  • Submitting events with the AWSPinpoint class.

Amazon Cognito user pools provide user directories that make it easier to add sign-up and sign-in to your app. As users authenticate with your app, Amazon Cognito reports authentication events to Amazon Pinpoint. For more information, see Using Amazon Pinpoint Analytics with Amazon Cognito User Pools in the Amazon Cognito Developer Guide.

If you don't want to use Amazon Cognito user pools, you can use the analyticsClient of the AWSPinpoint class to record and submit authentication events, as shown in the following examples. The event type is set to _userauth.sign_in, but you can substitute any authentication event type.

Objective-C

Copy
AWSPinpointEvent *event = _pinpoint.analyticsClient createEventWithEventType:@"_userauth.sign_in"]; _pinpoint.analyticsClient recordEvent:event]; _pinpoint.analyticsClient submitEvents];

Swift

Copy
let pinpointAnalyticsClient = pinpoint!.analyticsClient let event = pinpointAnalyticsClient.createEventWithEventType("_userauth.sign_in") pinpointAnalyticsClient.recordEvent(event) pinpointAnalyticsClient.submitEvents()

Reporting Custom Events

In addition to the standard events supported by Amazon Pinpoint, you can create custom events by assigning custom types to the events reported by your app. A custom event must have an event type, and you can add custom attributes and metrics.

After your app reports custom events, view the related analytics in the Amazon Pinpoint console. On the Analytics page, the Events tab provides metrics for all custom events reported by your app.

The following examples use the analyticsClient of the AWSPinpoint class to create a custom event.

Objective-C

AWSPinpointEvent *event = _pinpoint.analyticsClient createEventWithEventType:@"MyCustomEvent"];
    [event addAttribute:@"MyAttributeValue1" forKey:@"MyAttribute1"];
    [event addAttribute:@"MyAttributeValue2" forKey:@"MyAttribute2"];
    [event addMetric:[NSNumber numberWithInt:(arc4random() % 65535)] forKey:@"MyMetric"];
    _pinpoint.analyticsClient recordEvent:event];
    _pinpoint.analyticsClient submitEvents];

Swift

Copy
let pinpointAnalyticsClient = pinpoint!.analyticsClient let event = pinpointAnalyticsClient.createEventWithEventType("MyCustomEvent") event.addAttribute("MyAttributeValue1", forKey: "MyAttribute1") event.addAttribute("MyAttributeValue2", forKey: "MyAttribute2") event.addMetric(Int((arc4random() % 65535)), forKey: "MyMetric") pinpointAnalyticsClient.recordEvent(event) pinpointAnalyticsClient.submitEvents()