Purchase Event
A purchase event fires when a user completes a purchase. Based on Google Analytics 4 ecommerce event specifications.
DataLayer Example
window.dataLayer.push({
"event": "purchase",
"ecommerce": {
"transaction_id": "T_12345",
"value": 72.05,
"currency": "USD",
"coupon": "SUMMER_SALE",
"shipping": 5.99,
"tax": 3.6,
"customer_type": "new",
"items": [
{
"item_id": "SKU_12345",
"item_name": "Stan and Friends Tee",
"affiliation": "Google Merchandise Store",
"coupon": "SUMMER_FUN",
"discount": 2.22,
"index": 0,
"item_brand": "Google",
"item_category": "Apparel",
"item_category2": "Adult",
"item_category3": "Shirts",
"item_category4": "Crew",
"item_category5": "Short sleeve",
"item_list_id": "related_products",
"item_list_name": "Related Products",
"item_variant": "green",
"location_id": "ChIJIQBpAG2ahYAR_6128GcTUEo",
"price": 10.01,
"quantity": 1,
"promotion_id": "P_12345",
"promotion_name": "Summer Sale",
"creative_name": "summer_banner2",
"creative_slot": "featured_app_1",
"google_business_vertical": "retail"
}
]
}
});
Event Properties
| Property | Type | Constraints | Examples | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| event | string | const: "purchase" | The name of the event indicating a purchase has occurred. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ecommerce⤵ | object | Ecommerce related data for the purchase event. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ecommerce { }
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
View Raw JSON Schema
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://example.com/schemas/purchase-event.json",
"title": "Purchase Event",
"description": "A purchase event fires when a user completes a purchase. Based on Google Analytics 4 ecommerce event specifications.",
"type": "object",
"allOf": [
{
"$ref": "./components/dataLayer.json"
}
],
"properties": {
"event": {
"type": "string",
"const": "purchase",
"description": "The name of the event indicating a purchase has occurred."
},
"ecommerce": {
"type": "object",
"description": "Ecommerce related data for the purchase event.",
"properties": {
"transaction_id": {
"type": "string",
"description": "The unique ID of a transaction. The transaction_id parameter helps avoid duplicate transaction recording.",
"examples": [
"T_12345",
"TXN_20231205_001"
]
},
"value": {
"type": "number",
"description": "The monetary value of the event. Set value to the sum of (price * quantity) for all items in items.",
"examples": [
72.05,
99.99,
150.5
]
},
"currency": {
"type": "string",
"description": "The currency of the items in ISO 4217 three-letter format. Required when value is set.",
"minLength": 3,
"maxLength": 3,
"examples": [
"USD",
"EUR",
"GBP"
]
},
"coupon": {
"type": "string",
"description": "The coupon/code associated with the event. Event-level and item-level coupon parameters are independent.",
"examples": [
"SUMMER_SALE",
"WELCOME15"
]
},
"shipping": {
"type": "number",
"description": "The shipping cost associated with the transaction.",
"examples": [
5.99,
10,
0
]
},
"tax": {
"type": "number",
"description": "The tax associated with the transaction.",
"examples": [
3.6,
7.5,
0
]
},
"customer_type": {
"type": "string",
"enum": [
"new",
"returning"
],
"description": "Whether this is from a new or returning customer. 'new' = customer with no purchase in the specified time window (default 540 days). 'returning' = customer with purchase in the specified time window.",
"examples": [
"new",
"returning"
]
},
"items": {
"type": "array",
"description": "The products purchased in the transaction.",
"minItems": 1,
"items": {
"$ref": "./components/product.json"
}
}
},
"required": [
"transaction_id",
"value",
"currency",
"items"
]
}
}
}