Skip to content

Open source alternative to Semrush and Ahrefs

Carry the free check's domain through sign-up and onboarding (#937)

Carter Smith87efa62e2eb5
diff --git a/src/client/features/onboarding/PostSignupOnboarding.tsx b/src/client/features/onboarding/PostSignupOnboarding.tsx
index 84b86c57..e5130629 100644
--- a/src/client/features/onboarding/PostSignupOnboarding.tsx
+++ b/src/client/features/onboarding/PostSignupOnboarding.tsx
@@ -30,6 +30,8 @@ type PostSignupOnboardingProps = {
onFinish: () => void;
isSaving: boolean;
accountMenu: ReactNode;
+ /** Prefill for the website step, from the marketing site's free check. */
+ suggestedDomain?: string;
};
export function PostSignupOnboarding({
@@ -42,6 +44,7 @@ export function PostSignupOnboarding({
onFinish,
isSaving,
accountMenu,
+ suggestedDomain,
}: PostSignupOnboardingProps) {
const stepName = ONBOARDING_STEPS[step];
const isLastStep = step === ONBOARDING_LAST_STEP;
@@ -61,7 +64,11 @@ export function PostSignupOnboarding({
<OnboardingCard step={step + 1} total={ONBOARDING_LAST_STEP + 1}>
<fieldset disabled={isSaving} className="min-w-0">
{stepName === "website" ? (
- <WebsiteOnboardingStep onNext={onNext} onSkip={onSkip} />
+ <WebsiteOnboardingStep
+ onNext={onNext}
+ onSkip={onSkip}
+ suggestedDomain={suggestedDomain}
+ />
) : stepName === "search_console" ? (
<SearchConsoleOnboardingStep
onNext={onNext}
diff --git a/src/client/features/onboarding/WebsiteOnboardingStep.tsx b/src/client/features/onboarding/WebsiteOnboardingStep.tsx
index da08caea..b197b027 100644
--- a/src/client/features/onboarding/WebsiteOnboardingStep.tsx
+++ b/src/client/features/onboarding/WebsiteOnboardingStep.tsx
@@ -27,9 +27,11 @@ import { updateProject } from "@/serverFunctions/projects";
export function WebsiteOnboardingStep({
onNext,
onSkip,
+ suggestedDomain,
}: {
onNext: () => void;
onSkip: () => void;
+ suggestedDomain?: string;
}) {
const projectsQuery = useQuery(projectsQueryOptions());
const project = projectsQuery.data?.[0];
@@ -48,6 +50,7 @@ export function WebsiteOnboardingStep({
<WebsiteForm
key={project.id}
project={project}
+ suggestedDomain={suggestedDomain}
onNext={onNext}
onSkip={onSkip}
/>
@@ -72,10 +75,12 @@ const websiteSchema = z.object({
function WebsiteForm({
project,
+ suggestedDomain,
onNext,
onSkip,
}: {
project: ProjectSummary;
+ suggestedDomain?: string;
onNext: () => void;
onSkip: () => void;
}) {
@@ -108,7 +113,7 @@ function WebsiteForm({
const form = useAppForm({
defaultValues: {
- domain: project.domain ?? "",
+ domain: project.domain ?? suggestedDomain ?? "",
// New projects default to the United States.
market: {
locationCode: project.locationCode,
diff --git a/src/routes/_auth.sign-up.tsx b/src/routes/_auth.sign-up.tsx
index 574e1989..d27dd757 100644
--- a/src/routes/_auth.sign-up.tsx
+++ b/src/routes/_auth.sign-up.tsx
@@ -36,7 +36,11 @@ const signUpSchema = z
});
export const Route = createFileRoute("/_auth/sign-up")({
- validateSearch: authRedirectSearchSchema,
+ validateSearch: authRedirectSearchSchema.extend({
+ // A site checked with the marketing site's free tool; onboarding
+ // prefills it, and the website step validates it on save.
+ domain: z.string().optional().catch(undefined),
+ }),
component: SignUpPage,
});
@@ -44,7 +48,12 @@ function SignUpPage() {
const search = Route.useSearch();
const navigate = useNavigate();
const { redirectTo, isHostedMode } = useAuthPageState(search.redirect);
- const postSignupRedirect = redirectTo === "/" ? "/onboarding" : redirectTo;
+ const postSignupRedirect =
+ redirectTo !== "/"
+ ? redirectTo
+ : search.domain
+ ? `/onboarding?${new URLSearchParams({ domain: search.domain }).toString()}`
+ : "/onboarding";
const [showEmailForm, setShowEmailForm] = useState(false);
const google = useGoogleAuth({ redirectTo, postSignupRedirect });
diff --git a/src/routes/_authenticated.onboarding.index.tsx b/src/routes/_authenticated.onboarding.index.tsx
index 1f12f383..5871d7ae 100644
--- a/src/routes/_authenticated.onboarding.index.tsx
+++ b/src/routes/_authenticated.onboarding.index.tsx
@@ -3,6 +3,7 @@ import { createFileRoute, redirect, useNavigate } from "@tanstack/react-router";
import { useState } from "react";
import { PlanPageAccountMenu } from "@/client/features/billing/PlanPageAccountMenu";
import { PostSignupOnboarding } from "@/client/features/onboarding/PostSignupOnboarding";
+import { projectsQueryOptions } from "@/client/features/projects/projectQueries";
import {
buildOnboardingPayload,
ONBOARDING_LAST_STEP,
@@ -25,9 +26,16 @@ export const Route = createFileRoute("/_authenticated/onboarding/")({
// worker isolate cannot reuse another account's cached onboarding state.
ssr: false,
// Step lives in the URL so it survives refresh and works with back/forward.
- validateSearch: (search: Record<string, unknown>): { step: number } => {
+ // `domain` arrives from sign-up when the visitor checked a site with the
+ // marketing site's free keyword tool.
+ validateSearch: (
+ search: Record<string, unknown>,
+ ): { step: number; domain?: string } => {
const raw = Number(search.step);
- return { step: Number.isFinite(raw) ? clampStep(raw) : 0 };
+ return {
+ step: Number.isFinite(raw) ? clampStep(raw) : 0,
+ domain: typeof search.domain === "string" ? search.domain : undefined,
+ };
},
// Send users who already finished onboarding home before rendering. Running
// this in beforeLoad (not a component effect) means it can't race with the
@@ -64,7 +72,7 @@ function OnboardingFlow({
email: string | undefined;
}) {
const navigate = useNavigate();
- const { step } = Route.useSearch();
+ const { step, domain } = Route.useSearch();
const [answers, setAnswers] = useState<OnboardingAnswers>(initialAnswers);
const saveMutation = useMutation({
@@ -75,7 +83,10 @@ function OnboardingFlow({
});
const goToStep = (next: number) =>
- void navigate({ to: "/onboarding", search: { step: clampStep(next) } });
+ void navigate({
+ to: "/onboarding",
+ search: { step: clampStep(next), domain },
+ });
// Wait for the save before moving on, so a failure toast shows on the step
// the user can retry instead of on the next one.
@@ -121,7 +132,30 @@ function OnboardingFlow({
interests: answers.selectedInterests,
work_for: answers.workFor,
source: answers.source,
+ from_free_check: Boolean(domain),
});
+ // Visitors who signed up from the free keyword check came to see the rest
+ // of its results, so land them on the saved website's keywords ranking
+ // #4-20 instead of the dashboard.
+ if (domain) {
+ const [project] = await queryClient
+ .fetchQuery(projectsQueryOptions())
+ .catch(() => []);
+ if (project?.domain) {
+ void navigate({
+ to: "/p/$projectId/domain",
+ params: { projectId: project.id },
+ search: {
+ domain: project.domain,
+ minRank: 4,
+ maxRank: 20,
+ sort: "volume",
+ },
+ replace: true,
+ });
+ return;
+ }
+ }
void navigate({ to: "/", replace: true });
};
@@ -134,6 +168,7 @@ function OnboardingFlow({
onBack={() => goToStep(step - 1)}
onSkip={handleSkip}
onFinish={handleFinish}
+ suggestedDomain={domain}
isSaving={saveMutation.isPending}
accountMenu={<PlanPageAccountMenu email={email} />}
/>
diff --git a/web/src/components/campaign-pages.tsx b/web/src/components/campaign-pages.tsx
index 692af6b1..cd5dc04e 100644
--- a/web/src/components/campaign-pages.tsx
+++ b/web/src/components/campaign-pages.tsx
@@ -330,7 +330,7 @@ function ClientWins({ result }: { result: ClientKeywords }) {
free trial to research the keywords it should go after.
</p>
<div className="mt-4">
- <GateCta label="Start free trial" />
+ <GateCta label="Start free trial" domain={result.target} />
</div>
</div>
);
@@ -373,7 +373,10 @@ function ClientWins({ result }: { result: ClientKeywords }) {
))}
</ul>
<div className="absolute inset-0 flex flex-col items-center justify-center bg-white/50 px-4 text-center">
- <GateCta label={`See all ${rows.length} keywords`} />
+ <GateCta
+ label={`See all ${rows.length} keywords`}
+ domain={result.target}
+ />
<p className="mt-2 text-xs text-[var(--color-brand-muted)]">
Free trial. No credit card required.
</p>
@@ -381,7 +384,7 @@ function ClientWins({ result }: { result: ClientKeywords }) {
</div>
) : (
<div className="border-t border-[var(--color-border-subtle)] p-4 md:p-5">
- <GateCta label="Track these for your client" />
+ <GateCta label="Track these for your client" domain={result.target} />
<p className="mt-2 text-xs text-[var(--color-brand-muted)]">
Free trial. No credit card required.
</p>
@@ -410,10 +413,12 @@ function KeywordRow({ row }: { row: RankedKeywordRow }) {
);
}
-function GateCta({ label }: { label: string }) {
+/** Sign-up carries the checked site into onboarding, which lands the new
+ * account on that site's keywords ranking #4-20. */
+function GateCta({ label, domain }: { label: string; domain: string }) {
return (
<a
- href={SIGNUP_URL}
+ href={`${SIGNUP_URL}?${new URLSearchParams({ domain }).toString()}`}
onClick={() => trackTool("tool_cta_click", CLIENT_CHECK_TOOL)}
className="inline-flex min-h-11 w-full items-center justify-center rounded-lg bg-neutral-950 px-5 text-sm font-medium text-white transition-colors hover:bg-neutral-800 sm:w-auto"
>