In-App Purchase Module
The In-App Purchase module adds automatic tracking of in-app purchases to your app.
What is an in-app purchase?
An in-app purchase is additional content, services, or a subscription that you buy inside the app. Some examples of in-app purchases include:
- Upgrade to remove ads
- Game credits
- Virtual currency
- Extra game levels
- Unlock more features
Examples of purchases that are not considered in-app purchases include:
- Purchasing clothes or other items in an e-commerce app.
- Using Google Pay to complete a purchase.
Install
Install the In-App Purchase module using Maven (recommended) or manually.
Maven
To install the module using Maven:
- In your project’s top-level
build.gradle
file, add the following Maven repository:allprojects { repositories { mavenCentral() maven { url "https://maven.tealiumiq.com/android/releases/" } } }
- In your project module’s
build.gradle
file, add the following Maven dependencies:dependencies { implementation 'com.tealium:kotlin-core:1.6.0' implementation 'com.tealium:kotlin-inapp-purchase:1.0.2' }
Ensure you are using the latest version of kotlin-core.
Manual
To install the In-App Purchase module manually:
-
Download the Tealium In-App Purchase module.
-
Copy the file
tealium-kotlin.inapppurchase-1.0.2.aar
into your project’s<PROJECT_ROOT>/<MODULE>/libs
directory. -
Add the Tealium library dependency to your project module’s
build.gradle
file:dependencies { implementation(name:'tealium-kotlin.inapppurchase-1.0.2', ext:'aar') }
Initialize
Initialize the In-App Purchase module, as shown in the following example:
val config = TealiumConfig(application,
"ACCOUNT",
"PROFILE",
ENVIRONMENT,
modules = mutableSetOf(Modules.InAppPurchase),
dispatchers = mutableSetOf(
Dispatchers.Collect,
Dispatchers.RemoteCommands)
)
Data Layer
The In-App Purchase module sends the following attributes in the event:
Variable | Description | Example |
---|---|---|
purchase_order_id |
The order ID of the purchase. | “1234567890” |
purchase_timestamp |
The timestamp of the purchase in ISO 8601 format. | “2022-01-17T14:42:28Z” |
purchase_quantity |
The total number of items purchased. | “2” |
purchase_skus |
An array of the product IDs purchased. | [“premium_upgrade”, “sub”] |
purchase_state |
1 = Purchased, 2 = Pending, 0 = Unspecified (See Android Developers: Purchase.PurchaseState to learn more about this attribute.) | “1” |
purchase_is_auto_renewing |
Set to true if the subscription will auto-renew. |
true |
autotracked |
Set to true to indicate that the event was tracked automatically. |
true |
tealium_event |
The name of the event. | “in_app_purchase” |
This page was last updated: May 15, 2024