Skip to content

Instantly share code, notes, and snippets.

@kmclaugh
Last active September 8, 2021 15:28
Show Gist options
  • Save kmclaugh/b7a367b62b02010906630d3676cbdd1c to your computer and use it in GitHub Desktop.
Save kmclaugh/b7a367b62b02010906630d3676cbdd1c to your computer and use it in GitHub Desktop.
Pressed data layer changes
// just need to add products to the current setup
{
event: "checkoutContactStep | checkoutPaymentStep | checkoutReviewStep",
ecommerce: {
checkout: {
actionField: {
step: "{{checkout.step}}", // 1 // The checkout step (starting at 1).
},
products: [
{
id: "{{ product.id }}",
name: "{{product.title}}",
quantity: "{{product.quantity}}",
price: '{{product.price}}',
},
],
},
},
}
{
event: "membershipCancel",
membership: {
previousLevel: "{{previousLevel}}",
amount: "{{amount}}",
membershipId: "{{membershipId}}", // ?
},
}
{
event: "membershipSignup",
membership: {
level: "{{level}}", // vip or member
amount: "{{amount}}", // $0 or $10+
membershipId: "{{membershipId}}", // ?
},
}
{
event: "membershipUpgrade",
membership: {
level: "vip",
amount: "{{amount}}",
membershipId: "{{membershipId}}",
},
}
{
event: "productDetail",
ecommerce: {
detail: {
products: [
{
id: "{{ product.id }}",
name: "{{product.title}}",
quantity: "{{product.quantity}}",
price: '{{product.price}}',
},
],
},
},
}
{
event: "purchase",
ecommerce: {
currencyCode: "USD",
fulfillmentMethod: "{{fullfilment_method}}", // pressed post, etc
fulfillmenttType: "{{fullfilment_type}}", // ?
visitorType: "{{visitorType}}", // guest, member, etc
loyaltyPoint: "{{loyaltyPoint}}",
purchase: {
actionField: {
id: "{{checkout.order_number}}", // 12345 // The order number or transaction id
revenue: '{{checkout.total_price}}', // 11.00 // the total transaction value
tax: '{{checkout.tax_price}}', // 1.0 // the tax paid
shipping: '{{checkout.shipping_price}}', // 2.0 // cost of shipping
coupon: "{{discount.code}}", // SUMMER2020 // the discount code used
},
products: [
{
id: "{{ product.id }}",
name: "{{product.title}}",
quantity: "{{product.quantity}}",
price: '{{product.price}}',
upsell: true // this needs to persist all the way the checkout and purchase
},
],
},
},
}
{
event: "reloadLoyalty",
membership: {
level: "{{level}}",
amount: "{{amount}}", // amount reloaded
membershipId: "{{membershipId}}", //
},
}
{
event: "removeFromCart",
ecommerce: {
remove: {
products: [
{
id: "{{ product.id }}", // product that was removed
name: "{{product.title}}",
quantity: "{{product.quantity}}", // quantity that was removed
price: '{{product.price}}',
},
],
},
},
}
{
event: "addToCart",
ecommerce: {
add: {
actionField: {
list: "{{collection.title}} || cart", // 'fall collection' // Where the add to cart happened. use 'cart' if the removal happened on the cart page
},
products: [
{
id: "{{ product.id }}",
name: "{{product.title}}",
quantity: "{{product.quantity}}",
price: '{{product.price}}',
upsell: true // this needs to persist all the way the checkout and purchase
},
],
},
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment