-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[web] Add GA tracking for some onboarding actions
- Loading branch information
1 parent
390b30e
commit e13fa38
Showing
5 changed files
with
90 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import type * as Auth from "@umami/social-auth"; | ||
|
||
interface EventProps { | ||
eventName: GAEvent; | ||
params: Record<string, string | number | undefined>; | ||
} | ||
|
||
enum GAEvent { | ||
BUTTON_CLICK = "button_click", | ||
CONNECT_SUCCESS = "connect_success", | ||
} | ||
|
||
const trackGAEvent = ({ eventName, params }: EventProps) => { | ||
(window as any).gtag("event", eventName, { | ||
...params, | ||
surface: "web", | ||
}); | ||
}; | ||
|
||
export const trackSocialLoginButtonClick = (section: string, idp: Auth.IDP) => { | ||
trackGAEvent({ | ||
eventName: GAEvent.BUTTON_CLICK, | ||
params: { | ||
section, | ||
action: "social_login", | ||
idp, | ||
}, | ||
}); | ||
}; | ||
|
||
export const trackButtonClick = (section: string, action: string) => { | ||
trackGAEvent({ | ||
eventName: GAEvent.BUTTON_CLICK, | ||
params: { | ||
section, | ||
action, | ||
}, | ||
}); | ||
}; | ||
|
||
export const trackSuccessfulConnection = (section: string, type: string) => { | ||
trackGAEvent({ | ||
eventName: GAEvent.CONNECT_SUCCESS, | ||
params: { | ||
section, | ||
type, | ||
}, | ||
}); | ||
}; | ||
|
||
export const trackSuccessfulSocialConnection = (section: string, idp: Auth.IDP) => { | ||
trackGAEvent({ | ||
eventName: GAEvent.CONNECT_SUCCESS, | ||
params: { | ||
section, | ||
type: "social", | ||
idp, | ||
}, | ||
}); | ||
}; |