From 0ee7434188364dc230bbd034dc165a0f4850e3db Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Sat, 3 Jun 2023 11:16:32 +0700
Subject: Add gtag event on product detail

---
 src/lib/product/components/Product/Product.jsx | 6 ++++++
 1 file changed, 6 insertions(+)

(limited to 'src/lib/product/components/Product/Product.jsx')

diff --git a/src/lib/product/components/Product/Product.jsx b/src/lib/product/components/Product/Product.jsx
index 9521cbe4..351c07c1 100644
--- a/src/lib/product/components/Product/Product.jsx
+++ b/src/lib/product/components/Product/Product.jsx
@@ -5,6 +5,8 @@ import ProductDesktop from './ProductDesktop'
 import useAuth from '@/core/hooks/useAuth'
 import ProductMobile from './ProductMobile'
 import { useRouter } from 'next/router'
+import { useEffect } from 'react'
+import { gtagViewItem } from '@/core/utils/googleTag'
 
 const Product = ({ product }) => {
   const auth = useAuth()
@@ -26,6 +28,10 @@ const Product = ({ product }) => {
     wishlist.refetch()
   }
 
+  useEffect(() => {
+    gtagViewItem(product.variants)
+  }, [product])
+
   return (
     <>
       <ProductMobile product={product} wishlist={wishlist} toggleWishlist={toggleWishlist} />
-- 
cgit v1.2.3

