Post-Install Analytics Google Play
Before You Begin 🔗
Before you get started, you’ll need to:
- Integrate the latest Android SDK. Post-Install Analytics comes with SDK versions 5.0 and newer.
Obtain Google Play Public Key 🔗
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:
- 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).
- In the Application Details page, locate the Services and APIs link and click it.
- 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:
Set up item(s) with SKU(s) in Google Play Developer Console and note SKU(s):
- Add SKU(s) to project (in strings.xml)
onCreate, set up purchase flow for IAPs (one method is shown in line 54 of GoogleIAPTracking.java):
Use Google API to make purchase (line 79):
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
trackInAppGooglePlayPurchaseEventclass (line 127):
CBAnalytics.trackInAppGooglePlayPurchaseEvent(item.getTitle(), item.getDescription(), item.getPrice(), item.getCurrencyCode(), purchase.getSku(), data, signature);
- 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.)
Last modified November 27, 2023