Skip to main content
Version: 1.3.0

In-App Purchase

An in_app_purchase event example focused on Android and iOS Firebase implementations.

DataLayer Example

firebaseAnalytics.logEvent(FirebaseAnalytics.Event.IN_APP_PURCHASE) {
param(FirebaseAnalytics.Param.PRODUCT_ID, "sku_premium")
param(FirebaseAnalytics.Param.PRODUCT_NAME, "Premium Plan")
param(FirebaseAnalytics.Param.CURRENCY, "USD")
param(FirebaseAnalytics.Param.VALUE, 9.99)
param(FirebaseAnalytics.Param.SUBSCRIPTION, 1L)
param(FirebaseAnalytics.Param.FREE_TRIAL, 0L)
param(FirebaseAnalytics.Param.PRICE_IS_DISCOUNTED, 1L)
}

Event Properties

PropertyTypeConstraintsExamplesDescription
$schemastringrequired
"https://tracking-docs-demo.buchert.digital/schemas/1.3.0/mobile/in-app-purchase-event.json"
Defines the structure of the event.
const: "https://tracking-docs-demo.buchert.digital/schemas/1.3.0/mobile/in-app-purchase-event.json"
eventstringrequired
"in_app_purchase"
The event name for an in-app purchase.
const: "in_app_purchase"
product_idstringrequired
"sku_premium"
The purchased product identifier.
product_namestringrequired
"Premium Plan"
Display name of the purchased product.
currencystringrequired
"USD"
ISO 4217 currency code.
minLength: 3
maxLength: 3
valuenumberrequired
9.99
Purchase value.
subscriptionboolean
true
Whether the purchase is a subscription.
free_trialboolean
false
Whether a free trial was used.
price_is_discountedboolean
true
Whether the listed price is discounted.
additionalPropertiesSchema constraintControls properties not listed in properties and not matched by patternProperties.string, number, integer, boolean, null
View Raw JSON Schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://tracking-docs-demo.buchert.digital/schemas/1.3.0/mobile/in-app-purchase-event.json",
  "title": "In-App Purchase",
  "description": "An in_app_purchase event example focused on Android and iOS Firebase implementations.",
  "x-tracking-targets": [
    "android-firebase-kotlin-sdk",
    "android-firebase-java-sdk",
    "ios-firebase-swift-sdk",
    "ios-firebase-objc-sdk"
  ],
  "type": "object",
  "properties": {
    "$schema": {
      "type": "string",
      "description": "Defines the structure of the event.",
      "const": "https://tracking-docs-demo.buchert.digital/schemas/1.3.0/mobile/in-app-purchase-event.json"
    },
    "event": {
      "type": "string",
      "const": "in_app_purchase",
      "description": "The event name for an in-app purchase."
    },
    "product_id": {
      "type": "string",
      "description": "The purchased product identifier.",
      "examples": [
        "sku_premium"
      ]
    },
    "product_name": {
      "type": "string",
      "description": "Display name of the purchased product.",
      "examples": [
        "Premium Plan"
      ]
    },
    "currency": {
      "type": "string",
      "description": "ISO 4217 currency code.",
      "minLength": 3,
      "maxLength": 3,
      "examples": [
        "USD"
      ]
    },
    "value": {
      "type": "number",
      "description": "Purchase value.",
      "examples": [
        9.99
      ]
    },
    "subscription": {
      "type": "boolean",
      "description": "Whether the purchase is a subscription.",
      "examples": [
        true
      ]
    },
    "free_trial": {
      "type": "boolean",
      "description": "Whether a free trial was used.",
      "examples": [
        false
      ]
    },
    "price_is_discounted": {
      "type": "boolean",
      "description": "Whether the listed price is discounted.",
      "examples": [
        true
      ]
    }
  },
  "required": [
    "$schema",
    "event",
    "product_id",
    "product_name",
    "currency",
    "value"
  ],
  "allOf": [
    {
      "$ref": "https://tracking-docs-demo.buchert.digital/constraints/schemas/firebase/v1/flat-event-params.json"
    }
  ]
}