Skip to content

Instantly share code, notes, and snippets.

@saegeullee
Created February 15, 2021 06:08
Show Gist options
  • Select an option

  • Save saegeullee/69cdbc1e5627da0b9cf2c7d47a786f83 to your computer and use it in GitHub Desktop.

Select an option

Save saegeullee/69cdbc1e5627da0b9cf2c7d47a786f83 to your computer and use it in GitHub Desktop.
tagmanager
import TagManager from 'react-gtm-module';
function purchaseFunc() {
// ... purchase logic ...
const purchaseTag = {
dataLayer: {
event: 'purchase',
name: data.orderName,
price: data.totalPaymentPrice,
ecommerce: {
purchase: {
actionField: {
id: data.merchantUid,
affiliation: 'Mylight',
revenue: data.totalPaymentPrice,
tax: 0,
shipping: 0,
coupon: coupon ? coupon.couponName : '',
},
products: data.products?.map((product) => ({
name: product.packageName,
brand: 'Mylight',
category: PACKAGE_LANGUAGE_CODE[product.languageCode],
variant: data.paymentMethod,
quantity: product.orderQuantity,
price: product.paymentPrice,
})),
},
},
},
};
TagManager.dataLayer(purchaseTag);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment