URL referals to pricing page for Google Analytics

This commit is contained in:
Brandon Thomas committed 2023-01-24 03:31:54 -05:00
1 parent 6067bdbb44
commit c985f8bed7
6 files changed
+39 -22

No files matched your search

@@ -18,20 +18,35 @@ class FrontendUrlConfig {
return `/signup?sub=${pricingPlanKey}`;
}
static loginPage() : string {
return '/login';
}
// Pricing page
static pricingPage(): string {
return '/pricing';
}
static pricingPageWithReferer(fromPage: string): string {
// NB: This is to more easily track the referer page in Google Analytics
return `/pricing?from=${fromPage}`;
}
// Standalone pages
static aboutUsPage(): string {
return '/about';
}
static pricingPage(): string {
return '/pricing';
}
static termsPage(): string {
return '/terms';
}
static privacyPage(): string {
return '/privacy';
}
static patronsPage(): string {
return '/patrons';
}
@@ -16,6 +16,7 @@ import { container, sessionItem } from "../../../data/animation";
import { SessionSubscriptionsWrapper } from "@storyteller/components/src/session/SessionSubscriptionsWrapper";
import { Analytics } from "../../../common/Analytics";
import { SessionTtsAudioPlayer } from "./SessionTtsAudioPlayer";
import { FrontendUrlConfig } from "../../../common/FrontendUrlConfig";
interface Props {
ttsInferenceJobs: Array<TtsInferenceJob>;
@@ -166,7 +167,7 @@ function SessionTtsInferenceResultList(props: Props) {
<Trans i18nKey="common.SessionTtsInferenceResults.premium.ad">
Don't want to wait? Step to the front of the line with a{" "}
<Link
to="/pricing"
to={FrontendUrlConfig.pricingPageWithReferer("no_wait")}
onClick={() => {
Analytics.ttsTooSlowUpgradePremium();
}}
@@ -159,19 +159,19 @@ function FooterNav(props: Props) {
<div className="py-2 col-12 col-lg-3 d-flex flex-column gap-2 gap-lg-3 align-items-center align-items-lg-start">
<p className="fw-bold">Info</p>
<li>
<Link to="/pricing">Pricing</Link>
<Link to={FrontendUrlConfig.pricingPageWithReferer("footer")}>Pricing</Link>
</li>
<li>
<Link to="/about">About</Link>
<Link to={FrontendUrlConfig.aboutUsPage()}>About</Link>
</li>
<li>
<Link to="/terms">Terms of Use</Link>
<Link to={FrontendUrlConfig.termsPage()}>Terms of Use</Link>
</li>
<li>
<Link to="/privacy">Privacy Policy</Link>
<Link to={FrontendUrlConfig.privacyPage()}>Privacy Policy</Link>
</li>
<li>
<a href={FrontendUrlConfig.developerDocs()}>API Docs</a>
@@ -62,11 +62,11 @@ function TopNav(props: Props) {
let history = useHistory();
let myDataLink = "/signup";
let myDataLink = FrontendUrlConfig.signupPage();
if (props.sessionWrapper.isLoggedIn()) {
let username = props.sessionWrapper.getUsername();
myDataLink = `/profile/${username}`;
let username = props.sessionWrapper.getUsername() as string; // NB: Should be present if logged in
myDataLink = FrontendUrlConfig.userProfilePage(username);
}
// NB: The responses from the "job count" endpoint are cached in a distributed manner.
@@ -152,7 +152,7 @@ function TopNav(props: Props) {
let userOrLoginButton = (
<>
<Link to="/login">
<Link to={FrontendUrlConfig.loginPage()}>
<span className="nav-login me-4" data-bs-toggle="offcanvas">
{t("nav.TopNav.buttons.login")}
</span>
@@ -162,7 +162,7 @@ function TopNav(props: Props) {
let signupOrLogOutButton = (
<>
<Link to="/signup">
<Link to={FrontendUrlConfig.signupPage()}>
<button className="btn btn-primary" data-bs-toggle="offcanvas">
{t("nav.TopNav.buttons.signUp")}
</button>
@@ -183,7 +183,7 @@ function TopNav(props: Props) {
gravatar = <Gravatar email_hash={gravatarHash} size={15} />;
}
let url = `/profile/${displayName}`;
let url = FrontendUrlConfig.userProfilePage(displayName);
userOrLoginButton = (
<>
<Link className="btn btn-secondary me-3" to={url}>
@@ -326,7 +326,7 @@ function TopNav(props: Props) {
<ul className="navbar-nav justify-content-start align-items-lg-center flex-grow-1 gap-2 gap-lg-0">
<li data-bs-toggle="offcanvas" className="nav-item">
<Link
to={FrontendUrlConfig.pricingPage()}
to={FrontendUrlConfig.pricingPageWithReferer("topnav")}
onClick={() => { Analytics.topbarClickPricing() } }
className="nav-link"
>
@@ -243,7 +243,7 @@ function SignupPage(props: Props) {
let redirectWasSuccessful = await afterSignupRedirect();
if (!redirectWasSuccessful) {
window.location.href = FrontendUrlConfig.pricingPage();
window.location.href = FrontendUrlConfig.pricingPageWithReferer("signup");
}
}
@@ -257,7 +257,7 @@ function SignupPage(props: Props) {
return await BeginStripeCheckoutFlow(maybeInternalPlanKey);
}
let redirectUrl = FrontendUrlConfig.pricingPage();
let redirectUrl = FrontendUrlConfig.pricingPageWithReferer("signup");
history.push(redirectUrl);
return true;
@@ -13,6 +13,7 @@ import {
import { item, image } from "../../../../../data/animation";
import { motion } from "framer-motion";
import { Analytics } from "../../../../../common/Analytics";
import { FrontendUrlConfig } from "../../../../../common/FrontendUrlConfig";
interface Props {
sessionWrapper: SessionWrapper;
@@ -61,7 +62,7 @@ export function TtsPageHero(props: Props) {
viewPricingButton = (
<>
<Link
to="/pricing"
to={FrontendUrlConfig.pricingPageWithReferer("tts_hero_new")}
onClick={() => {
Analytics.ttsClickHeroViewPricing();
}}
@@ -76,8 +77,8 @@ export function TtsPageHero(props: Props) {
}
if (props.sessionWrapper.isLoggedIn()) {
let displayName = props.sessionWrapper.getDisplayName();
let url = `/profile/${displayName}`;
let displayName = props.sessionWrapper.getDisplayName() as string; // NB: If logged in, should be string
let url = FrontendUrlConfig.userProfilePage(displayName);
myProfileButton = (
<>
<Link
@@ -97,7 +98,7 @@ export function TtsPageHero(props: Props) {
upgradeButton = (
<>
<Link
to="/pricing"
to={FrontendUrlConfig.pricingPageWithReferer("tts_hero_user")}
onClick={() => {
Analytics.ttsClickHeroUpgradePlan();
}}