diff --git a/apps/web/src/views/auth/password.tsx b/apps/web/src/views/auth/password.tsx index 9d5aa870..8b5135f3 100644 --- a/apps/web/src/views/auth/password.tsx +++ b/apps/web/src/views/auth/password.tsx @@ -13,16 +13,6 @@ import { } from "#lib/utils"; import { useClient } from "#context"; -declare global { - interface Window { - gtag?: ( - type: string, - event: string, - options: { send_to: string; event_callback: () => void } - ) => void; - } -} - const PasswordForm: AuthFormComponent = (props) => { const client = useClient(); const [hidePassword, setHidePassword] = createSignal(true); @@ -68,10 +58,7 @@ const PasswordForm: AuthFormComponent = (props) => { redirect: props.redirect, plan: props.plan }); - window.gtag?.("event", "conversion", { - send_to: "AW-16595937003/5SD4CLf_vLcZEOvNx-k9", - event_callback: () => {} - }); + props.onRegister?.(); setLoading(false); props.setFormData("formType", "verify-email"); } catch (error) { diff --git a/apps/web/src/views/auth/view.tsx b/apps/web/src/views/auth/view.tsx index 55154f13..4a43117f 100644 --- a/apps/web/src/views/auth/view.tsx +++ b/apps/web/src/views/auth/view.tsx @@ -36,10 +36,21 @@ interface AuthFormComponentProps { redirect?: string; plan?: string; setFormData: SetStoreFunction; + onRegister?: () => void; } type AuthFormComponent = Component; +declare global { + interface Window { + gtag?: ( + type: string, + event: string, + options: { send_to: string; event_callback: () => void } + ) => void; + } +} + const AuthView: Component = () => { const hostConfig = useHostConfig(); const client = useClient(); @@ -71,8 +82,15 @@ const AuthView: Component = () => { setShowForm(true); } }; + const trackConversion = (): void => { + window.gtag?.("event", "conversion", { + send_to: "AW-16595937003/5SD4CLf_vLcZEOvNx-k9", + event_callback: () => {} + }); + }; const continueWithGitHub = (): void => { setFormData("loading", true); + trackConversion(); window.location.replace(`/login/github?plan=${plan}`); }; @@ -121,6 +139,9 @@ const AuthView: Component = () => { setFormData={setFormData} redirect={redirect} plan={plan} + onRegister={() => { + trackConversion(); + }} footer={ <>