Skip to content

Instantly share code, notes, and snippets.

@kaesetoast
Last active January 5, 2020 09:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kaesetoast/adcf967a31d5f9a7a2814f17e62e0a72 to your computer and use it in GitHub Desktop.
Save kaesetoast/adcf967a31d5f9a7a2814f17e62e0a72 to your computer and use it in GitHub Desktop.
DataLayer
// The dataLayer JavaScript is generated inside of a smarty template. All variables in curly-braces have to be replaced
// with whatever your system provides you with.
<script>
window.dataLayer = window.dataLayer || [];
dataLayer.push({
event: "orderCompleted",
transactionId: '{$sOrderNumber}', // Transaction ID. Required for purchases and refunds.
transactionTotal: {if $sAmountWithTax && $sUserData.additional.charge_vat}{$sAmountWithTax}{else}{$sAmount}{/if}, // Total transaction value (incl. tax and shipping)
transactionTax: {$sAmountTax},
transactionShipping: {$sShippingcosts},
transactionProducts: [
{foreach $sBasket.content as $key => $sBasketItem}
{
sku: "{$sBasketItem.ordernumber}",
name: "{$sBasketItem.articlename}", // Name or ID is required
price: {$sBasketItem.priceNumeric},
quantity: {$sBasketItem.quantity}
},
{/foreach}
]
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment