Skip to main content
Version: 1.3.0

Purchase Event

A purchase event sent via analytics.js-compatible CDPs using the track() call.

Code Example

analytics.track("Purchase", {
"userId": "user-123",
"revenue": 72.05,
"currency": "USD",
"order_id": "ORD-12345",
"products": [
{
"product_id": "SKU_12345",
"name": "Stan and Friends Tee",
"price": 10.01,
"quantity": 1
}
]
});

Event Properties

PropertyTypeConstraintsExamplesDescription
$schemastringrequired
"https://tracking-docs-demo.buchert.digital/schemas/analytics-js/track-purchase.json"
Defines the structure of the event.
const: "https://tracking-docs-demo.buchert.digital/schemas/analytics-js/track-purchase.json"
eventstringrequired
"Purchase"
The name of the event.
const: "Purchase"
userIdstring
"user-123"
The identifier for the user. Required for server-side tracking.
revenuenumber
72.05
99.99
150.5
The total revenue of the purchase.
currencystringminLength: 3
"USD"
"EUR"
"GBP"
The currency of the purchase in ISO 4217 three-letter format.
maxLength: 3
order_idstring
"ORD-12345"
"TXN-20231205-001"
The unique identifier for the order.
[]productsarrayThe list of products in the order.
product_idstring
"SKU_12345"
"PROD_98765"
The unique identifier for the product.
namestring
"Stan and Friends Tee"
"Blue Running Shoes"
The name of the product.
pricenumber
10.01
21.01
89.99
The price of the product.
quantitynumberdefault: 1
1
2
3
The quantity of the product.
View Raw JSON Schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://tracking-docs-demo.buchert.digital/schemas/analytics-js/track-purchase.json",
  "title": "Purchase Event",
  "description": "A purchase event sent via analytics.js-compatible CDPs using the track() call.",
  "x-tracking-targets": [
    "web-segment-js",
    "web-rudderstack-js",
    "web-hightouch-js",
    "server-rudderstack-php",
    "server-rudderstack-java",
    "server-rudderstack-python"
  ],
  "type": "object",
  "properties": {
    "$schema": {
      "type": "string",
      "description": "Defines the structure of the event.",
      "const": "https://tracking-docs-demo.buchert.digital/schemas/analytics-js/track-purchase.json"
    },
    "event": {
      "type": "string",
      "const": "Purchase",
      "description": "The name of the event."
    },
    "userId": {
      "type": "string",
      "description": "The identifier for the user. Required for server-side tracking.",
      "examples": [
        "user-123"
      ]
    },
    "revenue": {
      "type": "number",
      "description": "The total revenue of the purchase.",
      "examples": [
        72.05,
        99.99,
        150.5
      ]
    },
    "currency": {
      "type": "string",
      "description": "The currency of the purchase in ISO 4217 three-letter format.",
      "minLength": 3,
      "maxLength": 3,
      "examples": [
        "USD",
        "EUR",
        "GBP"
      ]
    },
    "order_id": {
      "type": "string",
      "description": "The unique identifier for the order.",
      "examples": [
        "ORD-12345",
        "TXN-20231205-001"
      ]
    },
    "products": {
      "type": "array",
      "description": "The list of products in the order.",
      "items": {
        "type": "object",
        "properties": {
          "product_id": {
            "type": "string",
            "description": "The unique identifier for the product.",
            "examples": [
              "SKU_12345",
              "PROD_98765"
            ]
          },
          "name": {
            "type": "string",
            "description": "The name of the product.",
            "examples": [
              "Stan and Friends Tee",
              "Blue Running Shoes"
            ]
          },
          "price": {
            "type": "number",
            "description": "The price of the product.",
            "examples": [
              10.01,
              21.01,
              89.99
            ]
          },
          "quantity": {
            "type": "number",
            "description": "The quantity of the product.",
            "examples": [
              1,
              2,
              3
            ],
            "default": 1
          }
        }
      }
    }
  },
  "required": [
    "$schema",
    "event"
  ]
}