From 2514824ca1a7cf1a8efc1e1bf406e179fe319d02 Mon Sep 17 00:00:00 2001 From: Italo Batista Date: Wed, 15 May 2019 15:52:50 -0300 Subject: [PATCH] Update CHANGELOG.md --- CHANGELOG.md | 4 +++- react/events/enhancedCommerce.ts | 8 +++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 83566e8..9f5e279 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] -## [0.4.0] - 2019-05-15 +### Added + +- Dispatch `productClick` events. ## [0.3.1] - 2019-05-14 diff --git a/react/events/enhancedCommerce.ts b/react/events/enhancedCommerce.ts index 5a921d2..837b142 100644 --- a/react/events/enhancedCommerce.ts +++ b/react/events/enhancedCommerce.ts @@ -22,16 +22,18 @@ const getSkuName = (selectedSku: string, items: Item[]) => * https://developers.google.com/analytics/devguides/collection/analyticsjs/enhanced-ecommerce#measuring-actvities */ export const productDetail = (product: Product) => { + if (!product) return + + const category = getCategory(product.categories) + ga('ec:addProduct', { brand: product.brand, - category: product.categoryId, + category: category, id: product.productId, name: product.productName, variant: getSkuName(product.selectedSku, product.items), }) - ga('ec:setAction', 'detail') - ga('send', 'event', { eventAction: 'Detail', eventCategory: 'Ecommerce',