# Post-Install Analytics iOS

## Before You Begin

Before you get started, you'll need to:

- Integrate the latest [iOS SDK](/en/monetization/integrate/ios/get-started/). Post-Install Analytics comes with SDK versions 5.0 and newer.



## Declaring a Chartboost Singleton

The header **`CBAnalytics.h`** contains the public methods that track IAP events. This class will only be usable if the session has been initialized (calling the `startWithAppId` method of the Chartboost class; see this page).



## IAP Tracking

In order to call IAP tracking methods, use the following static method, declared in `CBAnalytics.h`:



## API Methods

```
+(void) trackInAppPurchaseEvent:(NSData _)transactionReceipt  
                      product:(SKProduct _)product;
```

The **Product** object contains information about the item purchased, and the receipt will let us validate the transaction with Apple. (For more information, see Apple's [SKProduct class documentation](https://developer.apple.com/library/ios/documentation/StoreKit/Reference/SKProduct_Reference/Reference/Reference.html).)



## Testing Your PIA Setup

After completing the PIA integration, you can enable a sandbox mode to test your work, **before** submitting your game for App Store approval.

To do this, you'll need to enable a test mode flag in the Chartboost SDK via an environment variable in Xcode. Here's how:

1. Open the scheme section at the top-left corner of Xcode and pick **Edit Scheme** from the drop-down menu:

    ![](/assets/images/articles/2023_advertising_analytics_ios_001.png)

2. Click **Run** in the left-side menu and switch to the **Arguments** tab.

3. Click the + symbol in the **Environment Variables** section and type `CB_TEST_MODE` in the **Name** field that appears:

    ![](/assets/images/articles/2023_advertising_analytics_ios_002.png)

4. Double click the space beneath the **Value** title and enter `on` in the field that appears:

    ![](/assets/images/articles/2023_advertising_analytics_ios_003.png)

    After that, click **OK**, run your project, and make a purchase in development mode.

    Be sure to remove the `CB_TEST_MODE` environment variable before launching your game!

