diff --git a/src/libs/GoogleTagManager/index.native.ts b/src/libs/GoogleTagManager/index.native.ts index 267591d6ef40..aa10ffc4fe3c 100644 --- a/src/libs/GoogleTagManager/index.native.ts +++ b/src/libs/GoogleTagManager/index.native.ts @@ -1,11 +1,12 @@ +/* eslint-disable @typescript-eslint/naming-convention */ import analytics from '@react-native-firebase/analytics'; import Log from '@libs/Log'; import type {GoogleTagManagerEvent} from './types'; import type GoogleTagManagerModule from './types'; function publishEvent(event: GoogleTagManagerEvent, accountID: number) { - analytics().logEvent(event, {accountID}); - Log.info('[GTM] event published', false, {event, accountID}); + analytics().logEvent(event, {user_id: accountID}); + Log.info('[GTM] event published', false, {event, user_id: accountID}); } const GoogleTagManager: GoogleTagManagerModule = { diff --git a/src/libs/GoogleTagManager/index.ts b/src/libs/GoogleTagManager/index.ts index e859da8c12e9..c02fa899c9b4 100644 --- a/src/libs/GoogleTagManager/index.ts +++ b/src/libs/GoogleTagManager/index.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/naming-convention */ import Log from '@libs/Log'; import type {GoogleTagManagerEvent} from './types'; import type GoogleTagManagerModule from './types'; @@ -14,7 +15,7 @@ type WindowWithDataLayer = Window & { type DataLayerPushParams = { event: GoogleTagManagerEvent; - accountID: number; + user_id: number; }; declare const window: WindowWithDataLayer; @@ -24,8 +25,12 @@ function publishEvent(event: GoogleTagManagerEvent, accountID: number) { return; } - window.dataLayer.push({event, accountID}); - Log.info('[GTM] event published', false, {event, accountID}); + const params = {event, user_id: accountID}; + + // Pass a copy of params here since the dataLayer modifies the object + window.dataLayer.push({...params}); + + Log.info('[GTM] event published', false, params); } const GoogleTagManager: GoogleTagManagerModule = {