diff options
| author | trisusilo <tri.susilo@altama.co.id> | 2024-04-29 07:10:20 +0000 |
|---|---|---|
| committer | trisusilo <tri.susilo@altama.co.id> | 2024-04-29 07:10:20 +0000 |
| commit | d169ea22f8823f1bd9a94614ae2529677e0688ab (patch) | |
| tree | ea9bf55f86cb8e210757a0cc746164184072ad95 /src/core/utils | |
| parent | 1850e105ce6578465a015e395fa4c38544afdafe (diff) | |
| parent | 7da27cae381ad9cc6dfa1b4987cb0cc4e404c522 (diff) | |
Merged in agnes (pull request #137)
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..96a6bd2e 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.price_discount || 0, + // 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 |
