Purchase Tracking

Segmenting your users by their spending activity is one of the Tapjoy SDK’s most powerful features. For example, you might want to show advertisements to your non-spending users, but show In App Purchase promotions to your "whale" users. In order to use this feature, you must let Tapjoy know about the spending activity of your users. You do this with the Tapjoy.trackPurchase call.

In SDK 11.2.0 and later, there are separate calls for the Google Play store and Apple’s iTunes store, and you can pass in a receipt parameter so Tapjoy can verify that the purchase is valid before allowing the data into your dashboard:

1. Implementation

A. For Google Play Store:

Tapjoy.TrackPurchaseInGooglePlayStore(skuDetails, purchaseData, dataSignature, campaignId);

Explanation of Parameters:

  1. skuDetails – a String in JSON Object format that contains product item details (according to the Specification on Google Play)
  2. purchaseData – a String in JSON format that contains details about the purchase order. It is returned by the operating system after you make the purchase call. Use null to not use validation.
  3. dataSignature – String containing the signature of the purchase data that the developer signed with their private key. It is returned by the operating system after you make the purchase call. Use null to not use validation.
  4. campaignId – the campaign id of the PurchaseRequest if it initiated this purchase. This can be null if you don’t wish to track which campaign initiated this purchase.

In order for Purchase Tracking with receipt validation to work on Android, you must enter your application’s License Key into App Settings > Analytics > Receipt Validation.

You can find out how to get your application’s License Key from the Licensing section of the Google Services Documentation.

Example:

if (purchaseData == "" || purchaseData == null) { 
    purchaseData = "DATA_WAS_EMPTY"; 
}

if (dataSignature == "" || dataSignature == null) { 
    dataSignature = "SIGNATURE_WAS_EMPTY"; 
}

Tapjoy.TrackPurchaseInGooglePlayStore(skuDetails, purchaseData, dataSignature, campaignId);

B. For iOS App Store:

Tapjoy.TrackPurchaseInAppleAppStore("SWORD", "USD", 0.99, transactionID, null);

Explanation of Parameters:

  1. productId — the identifier of product as a string
  2. currencyCode– the currency code of price as an alphabetic currency code specified in ISO 4217, i.e. "USD", "KRW" as a string
  3. price — the price of product as a double
  4. transactionId — the identifier of iap transaction (i.e. the receipt iOS returns after completing an IAP transaction) as a string. If this is given, we will check receipt validation (Available in iOS 7.0 and later).
  5. campaignId — the campaign id of the purchase request which initiated this purchase as a string, can be null

Example:

if (transactionId == "" || transactionId == null) { 
    transactionId = "ID_WAS_EMPTY"; 
}
TapjoyUnity.Tapjoy.TrackPurchaseInAppleAppStore(productId, currencyCode, productPrice, transactionId, campaignId);

2. Non-verified Tracking:

For versions of SDK 11 earlier than 11.2.0, the tracking call is the following. Note that this example assumes you are doing receipt validation on your own:

Tapjoy.trackPurchase("SWORD", "USD", 0.99, null);

The currency codes used follow the ISO 4217 standard.

The fourth parameter is a campaign ID string that can be used to track which campaign generated a particular IAP purchase.

Once purchase tracking is implemented, you will be able to see charts in the "IAP Revenue" section of the dashboard.

3. Referrer (Android)

Integrate Tapjoy's InstallReferrerClient with Tapjoy Analytics

  1. In the start() method of your_project.cs class, call Tapjoy.ActivateInstallReferrerClient();
  2. Export Android project into Android Studio
  3. Add com.android.installreferrer:installreferrer in build.gradle <app_level>

4. FAQ

Can I use multiple Install Referrer Receivers?

Yes. Please refer to this article.

5. Important Note

You should either include the IAP purchase receipt with your Tapjoy IAP tracking call (for SDK versions 11.2.0 or higher), or verify that a given In-App Purchase is valid using Apple’s receipt validation measures or Google Play receipt validation (or whatever is appropriate for the store you are using) before reporting it to Tapjoy. If you do not do this, it is almost certain that your metrics and segmentation will be distorted by fraudulent purchases. This will break numerous Tapjoy capabilities, including the Future Value Map and the ability to target (or exclude) high-spending users with certain kinds of content.

The growth of IAP in freemium apps highlights a critical need for app developers to verify each purchase and guard against fraud. We highly suggest that you use receipt validation in your applications to prevent unauthorized transactions from contaminating your data. That way, you are incorporating valid (and only valid) purchases into your mobile analytics data. If you do not include a receipt parameter, we will assume that you did the receipt validation on your own and accept the purchase as valid.

Using IAP Receipt Verification and tracking your data on the Tapjoy Dashboard is simple and requires a minimal amount of work for app publishers.

You only need to make one single IAP tracking call for each purchase a user makes. By including the receipt parameter, you will eliminate revenue from fraudulent purchases showing up in your dashboard and will ensure that the IAP analytics remain accurate. You can pass the Apple or Google store receipt, along with your Tapjoy IAP tracking call, and Tapjoy’s servers will verify that the transaction is valid before adding it to your dashboard data.

Once you’ve completed receipt validation, you can confidently look at your data set, and Tapjoy’s Future Value Map, and target spenders with IAP promotions and non-spenders with ads in order to truly drive LTV from your users.