From c7e540c4973daf5c08a613c3890f91fc47cd7c8a Mon Sep 17 00:00:00 2001 From: "Shivam@RS" Date: Tue, 12 Jan 2021 15:00:19 +0530 Subject: [PATCH] Added Group call support for GA4 --- integrations/GA4/ECommerceEventConfig.js | 5 +++++ integrations/GA4/browser.js | 13 +++++++++++++ 2 files changed, 18 insertions(+) diff --git a/integrations/GA4/ECommerceEventConfig.js b/integrations/GA4/ECommerceEventConfig.js index 7010bb6f1d..52fb36c157 100644 --- a/integrations/GA4/ECommerceEventConfig.js +++ b/integrations/GA4/ECommerceEventConfig.js @@ -261,6 +261,11 @@ const eventNamesConfigArray = [ onlyIncludeParams: includeParams.CartShare, }, //--------- + { + src: ["group"], + dest: "join_group", + hasItem: false, + }, ]; export { diff --git a/integrations/GA4/browser.js b/integrations/GA4/browser.js index 4ec91ebb55..440fd7c216 100644 --- a/integrations/GA4/browser.js +++ b/integrations/GA4/browser.js @@ -19,6 +19,7 @@ export default class GA4 { this.sendUserId = config.sendUserId || false; this.blockPageView = config.blockPageViewEvent || false; this.extendPageViewParams = config.extendPageViewParams || false; + this.extendGroupPayload = config.extendGroupPayload || false; this.name = "GA4"; } @@ -215,4 +216,16 @@ export default class GA4 { window.gtag("event", "page_view", getPageViewProperty(pageProps)); } } + + group(rudderElement) { + const { groupId } = rudderElement.message; + const { traits } = rudderElement.message; + + getDestinationEventName(rudderElement.message.type).forEach((events) => { + this.sendGAEvent(events.dest, { + group_id: groupId, + ...(this.extendGroupPayload ? traits : {}), + }); + }); + } }