feat: track cloud sign_up event in dataLayer

Fires the sign_up dataLayer event already read by GTM for the three
signup paths on the cloud version: email/password (register.tsx),
GitHub/Google OAuth (via better-auth's newUserCallbackURL, distinct
from callbackURL so returning-user logins aren't counted), and
invitation acceptance. All gated behind isCloud, same as the rest of
the analytics wiring.
This commit is contained in:
Mauricio Siu
2026-08-14 09:09:27 -06:00
parent d542967ae4
commit d8b7c1ea5e
4 changed files with 10 additions and 0 deletions
@@ -13,6 +13,8 @@ export function SignInWithGithub() {
try { try {
const { error } = await authClient.signIn.social({ const { error } = await authClient.signIn.social({
provider: "github", provider: "github",
callbackURL: "/dashboard/home",
newUserCallbackURL: "/dashboard/home?signup=github",
errorCallbackURL: "/", errorCallbackURL: "/",
}); });
if (error) { if (error) {
@@ -13,6 +13,8 @@ export function SignInWithGoogle() {
try { try {
const { error } = await authClient.signIn.social({ const { error } = await authClient.signIn.social({
provider: "google", provider: "google",
callbackURL: "/dashboard/home",
newUserCallbackURL: "/dashboard/home?signup=google",
errorCallbackURL: "/", errorCallbackURL: "/",
}); });
if (error) { if (error) {
+4
View File
@@ -21,6 +21,7 @@ import {
FormMessage, FormMessage,
} from "@/components/ui/form"; } from "@/components/ui/form";
import { Input } from "@/components/ui/input"; import { Input } from "@/components/ui/input";
import { pushToDataLayer } from "@/lib/analytics";
import { authClient } from "@/lib/auth-client"; import { authClient } from "@/lib/auth-client";
import { api } from "@/utils/api"; import { api } from "@/utils/api";
import { useWhitelabelingPublic } from "@/utils/hooks/use-whitelabeling"; import { useWhitelabelingPublic } from "@/utils/hooks/use-whitelabeling";
@@ -139,6 +140,9 @@ const Invitation = ({
}); });
toast.success("Account created successfully"); toast.success("Account created successfully");
if (isCloud) {
pushToDataLayer("sign_up", { method: "invitation" });
}
router.push("/dashboard/home"); router.push("/dashboard/home");
} catch { } catch {
toast.error("An error occurred while creating your account"); toast.error("An error occurred while creating your account");
+2
View File
@@ -24,6 +24,7 @@ import {
FormMessage, FormMessage,
} from "@/components/ui/form"; } from "@/components/ui/form";
import { Input } from "@/components/ui/input"; import { Input } from "@/components/ui/input";
import { pushToDataLayer } from "@/lib/analytics";
import { authClient } from "@/lib/auth-client"; import { authClient } from "@/lib/auth-client";
import { useWhitelabelingPublic } from "@/utils/hooks/use-whitelabeling"; import { useWhitelabelingPublic } from "@/utils/hooks/use-whitelabeling";
@@ -116,6 +117,7 @@ const Register = ({ isCloud }: Props) => {
if (!isCloud) { if (!isCloud) {
router.push("/"); router.push("/");
} else { } else {
pushToDataLayer("sign_up", { method: "email" });
setData(data); setData(data);
} }
} }