Skip to content

Commit

Permalink
Fix call booking link redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
djfarrelly committed Jan 24, 2025
1 parent 1621b91 commit 6ea4c47
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/contact/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default function Page() {
eventVersion="2023-12-12.1"
gtmEvent="Sales Lead Form Submitted"
button="Schedule a call"
redirectTo="https://savvycal.com/inngest/demo"
redirectTo="https://savvycal.com/inngest/demo?utm_medium=website&utm_source=contact-page"
/>
</div>

Expand Down
4 changes: 2 additions & 2 deletions app/landing/ai/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default function Page() {
eventVersion="2023-12-12.1"
gtmEvent="Sales Lead Form Submitted"
button="Schedule a call"
redirectTo="https://savvycal.com/inngest/demo"
redirectTo="https://savvycal.com/inngest/demo?utm_medium=website&utm_source=ai-landing-page"
/>
}
showCTAs={false}
Expand All @@ -45,7 +45,7 @@ export default function Page() {
eventVersion="2023-12-12.1"
gtmEvent="Sales Lead Form Submitted"
button="Schedule a call"
redirectTo="https://savvycal.com/inngest/demo"
redirectTo="https://savvycal.com/inngest/demo?utm_medium=website&utm_source=ai-landing-page"
/>
</div>
</div>
Expand Down
29 changes: 24 additions & 5 deletions components/ContactForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import { useState } from "react";
import { useRouter } from "next/navigation";
import { cn } from "src/components/utils/classNames";

const CONTACT_KEY =
"Z-ymc97Dae8u4HHybHknc4DGRb51u6NnTOUaW-qG71ah1ZqsJfRcI6SaHg5APWutNcnMcaN3oZrZky-VQxBIyw";
const CONTACT_KEY = process.env.NEXT_PUBLIC_INNGEST_KEY;

const DEBUG = process.env.NEXT_PUBLIC_HOST.match(/localhost/) ? true : false;

export default function ContactForm({
eventName,
Expand Down Expand Up @@ -35,6 +36,7 @@ export default function ContactForm({
e.preventDefault();
setDisabled(true);
setButtonCopy("Sending...");

let ref = "";
try {
const u = new URLSearchParams(window.location.search);
Expand All @@ -43,7 +45,17 @@ export default function ContactForm({
}
} catch (err) {
// noop
if (DEBUG) {
console.error(err);
}
}

if (DEBUG) {
console.log("Debug mode enabled");
console.log("URL ref:", ref);
console.log("Redirect URL:", redirectTo);
}

try {
await window.Inngest.event(
{
Expand All @@ -63,17 +75,24 @@ export default function ContactForm({
if (redirectTo) {
setButtonCopy("Redirecting to scheduling...");
const redirectURL = new URL(redirectTo);
// If the URL of the page has a ref param, we override the UTM source
if (ref) {
redirectURL.searchParams.set("utm_source", ref);
}
// Assume it's a Savvycal call URL
redirectURL.searchParams.set("display_name", name);
redirectURL.searchParams.set("email", email);

if (DEBUG) {
console.log(redirectURL.toString());
}

router.push(redirectURL.toString());
// console.log(redirectURL.toString());
router.push(redirectTo);
} else {
setButtonCopy("Your message has been sent!");
}
} catch (e) {
console.warn("Message not sent");
console.warn("Message not sent", e);
setButtonCopy("Message not sent");
setDisabled(false);
}
Expand Down

0 comments on commit 6ea4c47

Please sign in to comment.