in_app_purchase
RecommendedappApp-stream event for an in-app product or subscription purchase. It may be collected automatically by the Firebase SDK/store integration; log it manually only when automatic purchase tracking is unavailable and avoid duplicate events.
- Platforms
- app
- When it fires
- You send it when the action happens.
Parameters (10)
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| currency | string | Yes* | Currency associated with value, in 3-letter ISO 4217 format. | USD |
| value | number | Yes* | Monetary value of the in-app purchase. | 30.03 |
| product_id | string | No | Product identifier. | ABC123456789 |
| product_name | string | No | Product name supported by Firebase Analytics SDKs. | Premium plan |
| price | number | No | Product price supported by Firebase Analytics SDKs. | 9.99 |
| quantity | number | No | Purchase quantity; defaults to 1 where supported. | 1 |
| subscription | boolean | No | Whether the purchase is a subscription. | true |
| free_trial | boolean | No | Whether the event is for a free trial subscription. | false |
| price_is_discounted | boolean | No | Whether the item price is discounted. | false |
| introductory_price | number | No | Introductory subscription price when supplied by automatic app purchase collection. | 4.99 |
Example
gtag.js
gtag('event', 'in_app_purchase', {
currency: 'USD',
value: 30.03,
product_id: 'ABC123456789',
product_name: 'Premium plan',
price: 9.99,
quantity: 1,
});GTM dataLayer
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
event: 'in_app_purchase',
currency: 'USD',
value: 30.03,
product_id: 'ABC123456789',
product_name: 'Premium plan',
price: 9.99,
quantity: 1,
});