Front-End Web & Mobile

Adding User Analytics to Your Mobile App

Having a single cloud provider as the backend to your mobile app has many advantages. One of these advantages is the tight integration of features between two or more AWS Cloud services. In this blog post, we show the benefits from the recent HAQM Cognito integration with HAQM Pinpoint for user analytics. You can now seamlessly collect user attributes like email and phone number automatically upon sign-up, track real-time user sign-up and sign-in activity, and then immediately engage your authenticated mobile users via push notification, email, and SMS based on demographics and user activity.

Do you want to engage users with a “welcome” message upon sign-up? Now you can.

Do you want to contact a user after X number of failed sign-ins? By tracking sign-in failures, you can contact users with instructions for resetting their password or provide additional help to get them going again.

First, let’s explore why this integration is useful for tracking and engagement and then we walk through the steps you can take to enable and start tracking mobile user authentication activities.

What does this integration provide mobile developers?

After the integration, all mobile user sign-ups, sign-ins, and authentication failures through HAQM Cognito User Pools are tracked and aggregated by HAQM Pinpoint. In addition to user activity tracking, authenticated user attributes (such as user email and phone number) are collected by your app client upon sign-up and shared with HAQM Pinpoint. These user attributes allow you to immediately engage your authenticated users through SMS, email, and push notification channels in HAQM Pinpoint.

Let’s get started

This integration requires a few actions for tracking to start.

Requirements

  • (Cloud) New or existing HAQM Cognito User Pool and HAQM Pinpoint app
  • (Mobile client) AWS Mobile SDK for iOS or Android (Android 2.6.2+ or iOS version 2.6.3+)

Step #1 Create an HAQM Pinpoint application ID

If you already have an HAQM Pinpoint app, proceed to Step 2.

If you don’t have an HAQM Pinpoint application, create a new project in the AWS Mobile Hub console. When you create an AWS Mobile Hub project, an HAQM Pinpoint app is created by default.

Step #2 Update general settings in your HAQM Cognito user pool

Sign in to the HAQM Cognito console.

  1. Choose Manage your User Pools.
  2. Choose an existing user pool to edit or choose the Create a user pool button.
  3. Choose the Analytics tab from the left navigation pane.
  4. Choose Add analytics and campaigns.
  5. Choose an HAQM Cognito app client (1) and HAQM Pinpoint project (2) and select Share user profile data with HAQM Pinpoint. (3). Manually type a name for the IAM role to be created and choose Create role. HAQM Cognito creates a new IAM role, which allows HAQM Cognito to submit events to HAQM Pinpoint on your behalf. (4). Choose Save changes (5)

Step #3 Update AWS Mobile SDK for Android or iOS

Yes. Unfortunetely you DO need to update your AWS Mobile SDK for Android and iOS.

  • Android v 2.6.2+
  • iOS v 2.6.3+

Step #4 Add your HAQM Pinpoint application ID to the CognitoUserPool setting in the client configuration file

Update your backend service configuration file (awsconfiguration.json) in your mobile project by adding your HAQM Pinpoint AppId to the CognitoUserPool setting as shown. The syntax is the same for iOS and Android projects.

Note: This platform independent file is generated per project by AWS Mobile Hub and identifies all your cloud backend resources (endpoints and configuration) that is used by the AWS Mobile SDKs.

  • [Android] AWS Mobile SDK for Android configuration.json file is under the res/raw folder in your Android Studio project.
  • [iOS] AWS Mobile SDK for iOS configuration.json file is typically located in the same root folder as your info.plist in your Xcode project.

[awsconfiguration.json]

Now build the app in your IDE, launch the app, and sign-up or sign-in to the app using the built-in native sign-up UX. Within a few minutes, you can track the built-in user activity in the Analytics section of the HAQM Pinpoint console. The tracking of the user activity looks like this.

Results, please!

Now that you are collecting and tracking user sign-up and sign-in activities in your app, you can easily engage with those users via HAQM Pinpoint. First, create a new segment in the HAQM Pinpoint console and choose one of the channels (mobile push, email, or SMS) of your registered users. You will see the number of users registered with your mobile app with that channel. You can then select various attributes collected by your app and immediately engage with these users by using an HAQM Pinpoint campaign. For more information, see HAQM Pinpoint Campaigns in the HAQM Pinpoint User Guide.

Stay engaged!