purchase
RecommendedLog this event when one or more items are purchased. Use a unique transaction_id to help prevent duplicate purchase reporting. customer_type can identify new versus returning customers.
- Platforms
- web, app
- When it fires
- You send it when the action happens.
Parameters (8)
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| currency | string | Yes* | Currency of the items associated with the event, in 3-letter ISO 4217 format. * If you set value then currency is required for revenue metrics to be computed accurately. | USD |
| transaction_id | string | Yes | The unique identifier of a transaction. The transaction_id parameter helps you avoid getting duplicate events for a purchase. | T_12345 |
| value | number | Yes* | The monetary value of the event. * value is required for meaningful reporting and to populate the purchasers predictive audience. * currency is required if you set value. | 12.21 |
| customer_type | string | No | Whether the conversion is from a new or returning customer. Use new or returning; omit when uncertain. | new |
| coupon | string | No | The coupon name/code associated with the event. Event-level and item-level coupon parameters are independent. | SUMMER_FUN |
| shipping | number | No | Shipping cost associated with a transaction. | 3.33 |
| tax | number | No | Tax cost associated with a transaction. | 1.11 |
| items | Array<Item> | Yes | The items for the event. | - |
Example
gtag.js
gtag('event', 'purchase', {
currency: 'USD',
transaction_id: 'T_12345',
value: 12.21,
items: [{ item_id: 'SKU_12345', item_name: 'Stan and Friends Tee', price: 9.99, quantity: 1 }],
customer_type: 'new',
coupon: 'SUMMER_FUN',
shipping: 3.33,
tax: 1.11,
});GTM dataLayer
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
event: 'purchase',
currency: 'USD',
transaction_id: 'T_12345',
value: 12.21,
items: [{ item_id: 'SKU_12345', item_name: 'Stan and Friends Tee', price: 9.99, quantity: 1 }],
customer_type: 'new',
coupon: 'SUMMER_FUN',
shipping: 3.33,
tax: 1.11,
});