Created
February 15, 2021 06:08
-
-
Save saegeullee/69cdbc1e5627da0b9cf2c7d47a786f83 to your computer and use it in GitHub Desktop.
tagmanager
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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