Skip to content

Commit 01627ef

Browse files
committed
feat: add support for setting user properties in GA
1 parent 8b0bc3b commit 01627ef

File tree

1 file changed

+8
-0
lines changed
  • src/Shared/Providers/ThemeProvider

1 file changed

+8
-0
lines changed

src/Shared/Providers/ThemeProvider/utils.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ export const setThemePreferenceInLocalStorage = (themePreference: ThemePreferenc
3030
export const logThemeToAnalytics = ({ appTheme, themePreference }: ThemeConfigType) => {
3131
const action = themePreference === THEME_PREFERENCE_MAP.auto ? `system-${appTheme}` : appTheme
3232

33+
if ('gtag' in window && window.gtag && typeof window.gtag === 'function') {
34+
window.gtag('set', 'user_properties', {
35+
appTheme,
36+
themePreference,
37+
})
38+
ReactGA.send('pageview')
39+
}
40+
3341
ReactGA.event({
3442
category: 'application-theme',
3543
action: `theme-changed-to-${action}`,

0 commit comments

Comments
 (0)