Skip to content

Instantly share code, notes, and snippets.

@prabapro
Last active July 10, 2022 05:18
Show Gist options
  • Save prabapro/4b9bc67ceff74b93a2ebb2dfd5720319 to your computer and use it in GitHub Desktop.
Save prabapro/4b9bc67ceff74b93a2ebb2dfd5720319 to your computer and use it in GitHub Desktop.
function() {
var orderData = {{dlv - order-data v1}};
var items = {{dlv - items - v1}};
var actionField = {
id: orderData.id,
affiliation: orderData.affiliation,
revenue: orderData.revenue,
shipping: orderData.shipping,
tax: orderData.tax
};
var products = items.map(function(prod) {
var item = {
id: prod.sku,
name: prod.name,
quantity: prod.quantity,
price: prod.price,
category: prod.category,
//Optional: Converting the "image" key into a custom dimension. Change the index as required.
dimension10: prod.image,
};
return item;
});
return {
ecommerce: {
currencyCode: orderData.currency,
purchase: {
actionField: actionField,
products: products
}
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment