Post-Install Analytics Integration for Google Play

Last Update:

Post-Install Analytics Integration for Google Play

Prerequisites

Before you get started, you'll need to:

If you're setting up PIA for Google Play games, you'll also need to add your app's public key to a field on the game's App Settings page:

Here's how to find your public key:

  1. Go to the Google Play Developer Console and sign in. Make sure that you sign in to the account from which the application you are licensing is published (or will be published)
  2. In the Application Details page, locate the Services and APIs link and click it
  3. In the Services and APIs page, locate the Licensing and In-App Billing section. You'll see your public key for in-app billing on this page.
Google Play PIA Integration
You'll find a sample project, InAppPurchase, that illustrates Google Play PIA functionality in our latest Android SDK package.

Our InAppPurchase sample project includes a GoogleIAPTracking.java file you can use to see PIA in action. Note that there are several ways to handle the IAP flow; below are highlights from the method our sample project uses:

1) Set up item(s) with SKU(s) in Google Play Developer Console and note SKU(s):

2) Add SKU(s) to project (in strings.xml)

3) In onCreate, set up purchase flow for IAPs (one method is shown in line 54 of GoogleIAPTracking.java):

4) Use Google API to make purchase (line 79):

5) After successful purchase, store purchase information in inventory, as shown in sample app (line 99). Once inventory stores information successfully, send information to the Chartboost SDK via the trackInAppGooglePlayPurchaseEvent class (line 127):

CBAnalytics.trackInAppGooglePlayPurchaseEvent(item.getTitle(),

        item.getDescription(),
        item.getPrice(),
        item.getCurrencyCode(),
        purchase.getSku(),
        data,
        signature);

6) Lastly, you can use a proxy service like Charles to verify that purchase data successfully reached our api/post-install-event/ endpoint. (Note: Even before this, null/empty purchase information will be flagged as such by errors in the log.)