Set up ROI360 in-app purchase and subscription revenue measurement

Premium

At a glance: Set up the AppsFlyer ROI360 in-app purchase and subscription revenue measurement solution.

About ROI360 in-app purchase and subscription revenue measurement

The ROI360 in-app purchase and subscription revenue measurement solution automatically validates and measures revenue from in-app purchases and auto-renewable subscriptions to give you the full picture of your customers' life cycles and accurate ROAS measurements.

Learn more about the solution

Setup

Typically, the setup involves multiple personas, including marketers, app developers, and perhaps a product or project manager.

The steps needed to set up the ROI360 in-app purchase and subscription revenue measurement solution include:

  1. Set up integration with Google Play
  2. Set up integration with iOS App Store
  3. Integrate the purchase SDK connector
  4. Test in-app purchase and subscription revenue measurement
  5. Release the app versions with the SDK connector

Details about each step are in the sections below.

Step 1: Set up integration with Google Play

Before you start:

  • Setting up in-app purchase and subscription revenue measurement consists of steps performed in Google Cloud Platform, Google Play Console, and in the AppsFlyer UI. We recommend you keep tabs for all 3 of those places open throughout the setup.
  • Setup in the AppsFlyer UI requires admin permissions.

Follow the instructions in the tabs below to set up notifications from Google Play.

1.1. Link your Google Play Developer Account to your Google Cloud Project

Prerequisites: Access to Google Play Console and Google Cloud Project.

To link your Google Play Developer Account to your Google Cloud Project:

  1. In the Google Play Console, go to your Google Play Developer Account.
  2. Link the account to your Google Cloud project. For instructions, see this Google help topic.
  3. Enable the Google Play Developer API. For instructions, see this Google help topic.

1.2. Configure your Service Account in the Google Cloud Platform

Prerequisites: Access to Google Cloud Platform.

To configure your service account:

  1. Create or locate the Service Account:
    1. In the Google Cloud Platform, go to the Service accounts section and click Create Service Account.
       
    2. Complete the service account details.
    3. Copy the email address.
    4. Click Create and continue.
    5. In the Grant this service account access to the project step, select the Pub/sub subscriber role.
    6. Click Continue > Done.
  2. Download the Service Account Private Key:
    1. In the Google Cloud Platform, go to the Service accounts section, find the account you want (the one you just created) from the list, and click the More actions icon.
    2. Click Manage keys.
    3. Click Add key > Create new key.
    4. In the Create private key popup, under Key type, select JSON, and click Create.
    5. Click Create. The private key JSON file is downloaded.
    6. Save the JSON key file, which will be uploaded to AppsFlyer later. Note! You must save the key; it can't be retrieved later. If you don't save it, you will have to create an entirely new key

1.3. Upload the Service Account Private Key to AppsFlyer

Prerequisites: Admin access to AppsFlyer.

To upload the Service Account Private Key to AppsFlyer:

  1. In AppsFlyer, from the side menu, select Settings > Revenue Settings, and select your app from the list.
  2. In the Purchases and subscriptions tab, click upload-2.png to upload the JSON file.
  3. Upload the JSON private key file.
  4. Click Save.

1.4. Set API access permissions in Google Play Console

Prerequisites: Access to Google Play Console.

Note: It can take time (sometimes even 24 hours) after setting service account credentials and permissions to be able to use them. This may cause you to receive errors in later steps.

To set API access permissions in Google Play Console:

  1. In the Google Play Console, go to Users and permissions, find the service account you created, and click Invite new users.
  2. Enter the Email address that you copied when you configured your service account in step 1.2.1.3.
     
  3. In the Permissions section, go to the Account permissions tab, and select both:
    • View financial data, orders, and cancellation survey responses.
    • Manage orders and subscriptions.
  4. Click Invite user.
  5. In the confirmation popup, click Send invite.

1.5. [Recommended] Send Google Play notifications directly to AppsFlyer

To receive in-app purchase and subscription revenue data from Google Play, you can either:

  • Create a topic where AppsFlyer directly receives the RTDN notifications from Google Play. This is the recommended option, and if you choose it, continue with the instructions below.
  • Set AppsFlyer as a subscriber to your pre-existing PUB/SUB topic. If you choose this option instead of the previous one, skip to the next step.

Prerequisites: Access to Google Play Console and AppsFlyer UI.

To send Google Play notifications directly to AppsFlyer:

  1. In AppsFlyer, from the side menu, go to Settings > Revenue Settings, select your app, and in the Purchases & subscriptions tab, select Allow AppsFlyer topic to get RTDN messages directly from Google.
  2. Copy the AppsFlyer topic to the clipboard.
  3. In Google Play Console > Home, select to view your app. The dashboard opens.
  4. Go to Monetize with Play > Monetization setup, and in the Google Play Billing section, make sure Enable real-time notification is checked.
  5. in the Topic name field, paste the AppsFlyer topic address you copied.
  6. For Notification content, select Subscriptions, voided purchases, and all one-time products.
  7. Click Save Changes.
    It can take time (sometimes even 24 hours) for this to take effect. Therefore, wait before testing.

1.6. [Optional] Forward Google Play notifications to AppsFlyer

Note: This step is only for when you didn’t choose the recommended method to receive in-app purchase and subscription revenue data from Google Play by sending notifications directly to AppsFlyer. If you completed the steps for the recommended method, to create a topic where AppsFlyer directly receives the RTDN notifications from Google Play, skip this step.

If instead, you want to set AppsFlyer as a subscriber to your pre-existing PUB/SUB topic, continue with the instructions below.

Prerequisites: Access to Google Cloud Platform and AppsFlyer UI.

To forward Google Play notifications to AppsFlyer:

  1. In AppsFlyer, from the side menu, go to Settings > Revenue Settings, select your app, and in the Purchases & subscriptions tab, select Forward your RTDN topic messages to AppsFlyer.
  2. Copy the endpoint URL to the clipboard.
  3. In Google Cloud Platform, under your project, search for Pub/Sub.
  4. In Pub/Sub go to the Topics section, and verify you have a dedicated pub/sub topic for subscriptions.
  5. In Pub/Sub go to the Subscriptions section, and click Create subscription.
  6. Enter the Subscription ID.
  7. Select the relevant subscription pub/sub topic from the dropdown.
  8. For Delivery type, select Push.
  9. Paste the Endpoint URL that you copied from AppsFlyer.
  10. For Expiry period, select Never expire.
  11. Click Create.
  12. Go to the Subscriptions section and click into the Topic name you want.
  13. Copy the topic name to the clipboard.
  14. In Google Play Console, go to Monetize with Play > Monetization setup, and in the Google Play Billing section, in the Topic name field, paste the topic name that you copied in the previous step.
  15. For Notification content, select Subscriptions, voided purchases, and all one-time products.
  16. Click Save changes.
    It can take time (sometimes even 24 hours) for this to take effect. Therefore, wait before testing.

1.7. Select revenue measurement types in AppsFlyer

To select the revenue measurement types:

  1. In AppsFlyer, from the side menu, select Settings > Revenue Settings > Purchases and subscriptions, and turn on either or both:
    • Validate purchases with Google Play.
    • Attribute and record auto-renewable subscriptions.
  2. [Optional] Check Allow AppsFlyer to deduplicate transactions that were already reported. This ensures no duplicate transactions are recorded.
  3. [Optional] Check Allow AppsFlyer to automatically follow up on pending, deferred or refunded transactions on my behalf. This allows AppsFlyer to correctly record all transactions.
  4. Click Save.
    It can take time (sometimes even 24 hours) for this to take affect. Therefore, wait before testing.

Step 2: Set up integration with iOS App Store

Before you start:

  • Setting up in-app purchase and subscription revenue consists of steps performed in App Store Connect and in the AppsFlyer UI. Keep tabs to both App Store Connect and AppsFlyer open during setup.
  • Setup in the AppsFlyer UI requires admin permissions.
  • Your iOS app requires StoreKit v1, which provides the framework for handling in-app purchases and subscriptions.

Follow the instructions in the tabs below to set up notifications from the App Store.

2.1 Get your App Store Connect shared secret key

To get you App Store Connect shared secret key:

  1. In App Store Connect, select your app. Go to General > App Information and scroll down to App-Specific Shared Secret, and click Manage to get the App Store Connect shared secret key.
     
  2. Copy the key to your clipboard and click Done.
     

2.2 Upload the shared secret key to AppsFlyer

To upload your shared secret key:

  1. In AppsFlyer, from the side menu, select Settings > Revenue Settings > Purchases and subscriptions
    The Revenue configuration page opens.
     
  2. Enter your App Store Connect shared secret key.

2.3 [Recommended] Send App Store notifications directly to AppsFlyer

Apple can only send server notifications to one endpoint, either to the AppsFlyer endpoint (best practice) or to your endpoint (and you then forward the notifications to AppsFlyer).

If you choose the recommended option, to send notifications directly to AppsFlyer, continue with the instructions below.

If you choose to forward notifications from your endpoint to AppsFlyer, skip to the next step.

To send notifications directly to AppsFlyer:

  1. In AppsFlyer revenue settings, copy the AppsFlyer server notifications endpoint to enter it in your App Store Connect configuration.
     
  2. In App Store Connect, in the App Information section, scroll to App Store Server Notifications, and next to Production Server URL, click Edit.
     
  3. Paste the URL copied from AppsFlyer, select Version 2 Notifications, and click Save.
  4. In App Store Connect, in the App Information section, scroll to App Store Server Notifications, and next to Sandbox Server URL, click Edit.
     
  5. Paste the URL copied from AppsFlyer, select Version 2 Notifications, and click Save.
  6. If you want to receive a copy of the notifications, in AppsFlyer, enter your Notification forwarding endpoint and click Save.
     

2.4 [Optional] Forward notifications from your endpoint to AppsFlyer

Note: This step is only for when you didn’t choose the recommended method to send notifications directly to AppsFlyer. If you completed the steps for the recommended method, skip this step.

If instead, you want to send notifications to your endpoint and then forward them from your endpoint to AppsFlyer, continue with the instructions below.

To forward server notifications from your endpoint to AppsFlyer:

  1. In App Store Connect, in the App Information section, scroll to App Store Server Notifications, and next to Production Server URL, click Edit.  
  2. Paste your endpoint URL, select Version 2 Notifications, and click Save.
  3. In App Store Connect, in the App Information section, scroll to App Store Server Notifications, and next to Sandbox Server URL, click Edit.
     
  4. Paste your endpoint URL, select Version 2 Notifications, and click Save.
     
  5. Configure the sending of the Apple server notifications from your backend to the AppsFlyer notification endpoint URL. Note: The requests must be exactly as they're received from the App Store. See Apple format requirements 

2.5 Select revenue measurement types in AppsFlyer

  1. In the AppsFlyer in-app purchase and subscription revenue configuration page, turn on either or both:
    • Attribute and record auto-renewable subscriptions (ARS).
    • Validate purchases with the Apple App Store.
  2. [Optional] Check Allow AppsFlyer to deduplicate transactions that were already reported.
    This ensures no duplicate transactions are recorded.
  3. [Optional] Check Allow AppsFlyer to automatically report negative revenue for transactions refunds. This ensures that refunds, cancellations, etc. are recorded.
  4. [Optional] Check Deduplicate revenue for Family Sharing purchases.
    This ensures no duplicate revenue is recorded for family-sharing purchases. Revenue events for other family members include the parameter purchase_ownership_type=FAMILY_SHARED and display zero revenue.

Step 3: Integrate the purchase SDK connector

To integrate the SDK connector:

Step 4: Test in-app purchase and subscription revenue measurement

It's best to test the in-app purchase and subscription revenue integrations in a sandbox environment to make sure that the SDK connector is properly integrated and that server notifications are properly configured and received by AppsFlyer.

Prior to the test, make sure your developer configures Sandbox environment in the SDK connector (by setting Sandbox to true). This allows ROI360 to create only Sandbox in-app events with 0 revenue for tests. Thus, production data isn't affected.

Sandbox environment considerations

In a sandbox environment:

  • Only initial purchase events cause the SDK connector to produce an event that is recorded by AppsFlyer. An in-app purchase event is called af_purchase_sandbox_sdk. A subscription event is called af_ars_sandbox_sdk. 
  • All other purchase events are dropped, meaning the SDK connector doesn’t produce an event.
  • Incoming server notifications are only processed if the SDK connector first records the original transaction. In this case, an in-app purchase event is produced called af_purchase_sandbox_s2s. A subscription event is produced called af_ars_sandbox_s2s.
  • An event isn’t produced for any server notification for which the SDK connector didn’t first record the original transaction.
  • For iOS, make sure that under App Store Server Notifications in App Store connect, the AppsFlyer endpoint is configured as your Sandbox Server URL.
    ASSN.png
  • For iOS, if the af_purchase_sandbox_sdk event contains the af_sandbox_revenue parameter with a revenue value, it means that in production, it would be a regular af_purchase event. If there's no revenue, in production it would be an af_purchase_free event.
  • For Android, tests performed by License Testers result in Sandbox events even if Sandbox environment in the SDK isn't configured.

Test in-app purchase and subscription revenue

To test in-app purchase and subscription revenue:

  1. Tell your developers to follow their Android, iOS, and Unity instructions to configure Sandbox environment in the SDK Connector.
  2. Make a test purchase. Transactions performed by License Tester in Google Play and from TestFlight in iOS are also supported.
    Note: Any subscription product can be tested only once from each testing device. In other words, you cannot register multiple test purchases of the same subscription from the same device, as they will not be recorded.
  3. Verify the event displays in the AppsFlyer Activity dashboard. An in-app purchase event is called af_purchase_sandbox_sdk. A subscription event is called af_ars_sandbox_sdk. These events include:
    • A revenue value of 0 (so as not to skew real AppsFlyer reports).
    • An af_sandbox_revenue parameter that includes the revenue value of the product purchased so you can ensure the correct revenue is reported.
  4. If you’re testing a subscription product, give some time for AppsFlyer to receive a server notification from. Usually this occurs within a few minutes after the initial purchase. 
  5. Verify an event displays in the AppsFlyer Activity dashboard. An auto-renewable subscription purchase is called af_ars_sandbox_s2s. The event includes:
    • A revenue value of 0 (so as not to skew real AppsFlyer reports).
    • An af_sandbox_revenue parameter that includes the revenue value of the product purchased so you can ensure the correct revenue is reported.

Step 5: Release the app versions with the SDK connector

With everything from the previous steps configured and the AppsFlyer purchase SDK connector integrated into your app, tell your developer to release the app version with the SDK connector integrated.

However, before the developer releases the new app version, make sure that:

  • The in-app events you want to capture as an in-app purchase or subscription aren't blocked by one of the Validation Rules you have configured in AppsFlyer.
  • Your developer should have any sandbox flags marked as false.
  • For iOS, make sure that under App Store Server Notifications in App Store connect, the AppsFlyer endpoint is configured as your Sandbox Server URL.
    ASSN.png

Once the app with the SDK connector is released, in-app purchase and subscription events will be generated and made available across all AppsFlyer dashboards, as well as in aggregated and raw data reports, including Revenue ETL.

Note: Events will only be generated for users who have updated to a version of the app that includes the SDK connector. As a result, until full adoption of the updated app version, a discrepancy between the revenue data from the app and the store data is expected.