|
/* |
|
* action: purchase |
|
* description: fire when the user actually completes the purchase |
|
* required fields: actionField.id, actionField.revenue , product.id, product.name, product.quantity, product.price, product.variant (if applicable) |
|
* reference: https://www.simoahava.com/analytics/enhanced-ecommerce-guide-for-google-tag-manager/#purchase |
|
*/ |
|
window.dataLayer = window.dataLayer || []; |
|
window.dataLayer.push({ |
|
event: "eec.purchase", |
|
eecEventName: "Purchase", |
|
ecommerce: { |
|
currencyCode: "USD", // USD // the currency of the checkout |
|
purchase: { |
|
actionField: { |
|
id: "{{checkout.order_number}}", // 12345 // The order number or transaction id |
|
affiliation: "Win Reality", |
|
revenue: |
|
'{{checkout.total_price}}', // 24.00 // the total transaction value if annual use the annual amount $199 |
|
tax: '{{checkout.tax_price}}', // 1.0 // the tax paid |
|
shipping: |
|
'{{checkout.shipping_price}}', // 2.0 // cost of shipping |
|
coupon: "{{discount.code}}", // SPRING // the discount code used |
|
}, |
|
products: [ |
|
{ |
|
// the membership info: |
|
id: "{{ product.id }}", // 'P12345' // use product id not variant id |
|
name: "{{product.title}}", // 'Player/Parent, Coach/Academy' |
|
quantity: "{{product.quantity}}", // 1 |
|
brand: "Win Reality", |
|
price: '{{product.price}}', // 24.00 // make sure the price is a number ie 10.00 not $10.00 |
|
variant: "{{product.headset}}", // 'Baseball or Softball or Both' |
|
// requires product-scoped custom dimensions: |
|
role: "{{product.role}}", // 'Player/Parent, Coach/Academy' |
|
}, |
|
{ |
|
// the hitting accessory is true: |
|
id: "{{ product.id }}", // 'P12345' // use product id not variant id |
|
name: "Hitting", // 'Hitting' |
|
quantity: "{{product.quantity}}", // 1 |
|
brand: "Win Reality", |
|
price: '{{product.price}}', // 24.00 // make sure the price is a number ie 10.00 not $10.00 |
|
// requires product-scoped custom dimensions: |
|
role: "{{product.role}}", // 'Player/Parent, Coach/Academy' |
|
}, |
|
], |
|
}, |
|
}, |
|
}); |