diff options
| author | tri.susilo <tri.susilo@altama.co.id> | 2024-04-29 13:02:14 +0700 |
|---|---|---|
| committer | tri.susilo <tri.susilo@altama.co.id> | 2024-04-29 13:02:14 +0700 |
| commit | 71e6f6b70601a5a6fa20645c2f01a6bf9f7b19ff (patch) | |
| tree | 6fa1e7a86d8877946a467ae40251caebd887c574 /src/core/utils | |
| parent | d3426a5d63add6e17cfcd0aefb01882e77eb4735 (diff) | |
google tag
Diffstat (limited to 'src/core/utils')
| -rw-r--r-- | src/core/utils/googleTag.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/core/utils/googleTag.js b/src/core/utils/googleTag.js index cc6d1283..65fad570 100644 --- a/src/core/utils/googleTag.js +++ b/src/core/utils/googleTag.js @@ -33,6 +33,20 @@ const sumTotal = (variants) => { } } +const mapProducts = (product) => { + const res = { + item_id: product.id, + item_name: product.name, + discount: product.lowest_price.priceDiscount, + // index: 0, + item_brand: product.manufacture.name, + item_category: product.categories, + item_variant: product.variants, + price: product.lowest_price.price, + quantity: product.stock_total + } + return res +} export const gtagAddToCart = (variant, quantity) => { const param = { currency: 'IDR', @@ -77,3 +91,13 @@ export const gtagPurchase = (variants, shipping, transactionId) => { } gtag('event', 'purchase', param) } + +export const gtagProductDetail = (product) => { + const items = mapProducts(product) + const param = { + currency: 'IDR', + value: product.id, + items + } + gtag('event', 'view_item', param) +}
\ No newline at end of file |
