Purchase Event
A purchase event sent via analytics.js-compatible CDPs using the track() call.
Code Example
- Segment (JS)
- RudderStack (JS)
- Hightouch (JS)
- RudderStack (PHP)
- RudderStack (Java)
- RudderStack (Python)
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
}
]
});
rudderanalytics.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
}
]
});
htevents.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
}
]
});
Rudder::track([
'userId' => 'user-123',
'event' => 'Purchase',
'properties' => [
'revenue' => 72.05,
'currency' => 'USD',
'order_id' => 'ORD-12345',
'products' => [
[
'product_id' => 'SKU_12345',
'name' => 'Stan and Friends Tee',
'price' => 10.01,
'quantity' => 1,
],
],
],
]);
analytics.enqueue(TrackMessage.builder("Purchase")
.userId("user-123")
.properties(ImmutableMap.builder()
.put("revenue", 72.05)
.put("currency", "USD")
.put("order_id", "ORD-12345")
.put("products", ImmutableList.of(
ImmutableMap.builder()
.put("product_id", "SKU_12345")
.put("name", "Stan and Friends Tee")
.put("price", 10.01)
.put("quantity", 1)
.build()
))
.build()));
rudder_analytics.track('user-123', 'Purchase', {
'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
| Property | Type | Constraints | Examples | Description |
|---|---|---|---|---|
| $schema | string | required | | Defines the structure of the event. |
const: "https://tracking-docs-demo.buchert.digital/schemas/analytics-js/track-purchase.json" | ||||
| event | string | required | | The name of the event. |
const: "Purchase" | ||||
| userId | string | | The identifier for the user. Required for server-side tracking. | |
| revenue | number | | The total revenue of the purchase. | |
| currency | string | minLength: 3 | | The currency of the purchase in ISO 4217 three-letter format. |
maxLength: 3 | ||||
| order_id | string | | The unique identifier for the order. | |
| []products | array | The list of products in the order. | ||
| product_id | string | | The unique identifier for the product. | |
| name | string | | The name of the product. | |
| price | number | | The price of the product. | |
| quantity | number | default: 1 | | The quantity of the product. |
View Raw JSON Schema
{
: "https://json-schema.org/draft/2020-12/schema",
: "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"
]
}