Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Add UTM params for all nav links

Tim Wilson75b469c3a40b
diff --git a/packages/ui/src/nav/content/company-content.tsx b/packages/ui/src/nav/content/company-content.tsx
index a787b19c19..296ac24f48 100644
--- a/packages/ui/src/nav/content/company-content.tsx
+++ b/packages/ui/src/nav/content/company-content.tsx
@@ -3,6 +3,7 @@ import { COMPANY, SOCIAL_LINKS } from "../../content";
import {
contentHeadingClassName,
ContentLinkCard,
+ getUtmParams,
LargeLinkCard,
} from "./shared";
@@ -17,7 +18,11 @@ export function CompanyContent({ domain }: { domain: string }) {
description={description}
icon={icon}
iconClassName="size-5"
- href={createHref(href, domain)}
+ href={createHref(
+ href,
+ domain,
+ getUtmParams({ domain, utm_content: title }),
+ )}
/>
))}
</div>
diff --git a/packages/ui/src/nav/content/product-content.tsx b/packages/ui/src/nav/content/product-content.tsx
index 15aaac287b..f111bde66f 100644
--- a/packages/ui/src/nav/content/product-content.tsx
+++ b/packages/ui/src/nav/content/product-content.tsx
@@ -8,6 +8,7 @@ import {
ContentLinkCard,
LargeLinkCard,
contentHeadingClassName,
+ getUtmParams,
} from "./shared";
const largeLinks = [
@@ -30,7 +31,11 @@ export function ProductContent({ domain }: { domain: string }) {
<div className="grid w-[1020px] grid-cols-[minmax(0,1fr),0.4fr] divide-x divide-gray-200">
<div className="grid grid-cols-2 gap-4 p-4">
<Link
- href={createHref("/home", domain)}
+ href={createHref(
+ "/home",
+ domain,
+ getUtmParams({ domain, utm_content: "Dub Links" }),
+ )}
className="group relative flex flex-col overflow-hidden rounded-xl border border-neutral-100 bg-neutral-50 dark:border-white/20 dark:bg-white/10"
>
<div className="p-5 pb-0">
@@ -48,7 +53,11 @@ export function ProductContent({ domain }: { domain: string }) {
</Link>
<div className="flex flex-col gap-4">
<Link
- href={createHref("/analytics", domain)}
+ href={createHref(
+ "/analytics",
+ domain,
+ getUtmParams({ domain, utm_content: "Dub Analytics" }),
+ )}
className="group relative flex flex-col overflow-hidden rounded-xl border border-neutral-100 bg-neutral-50 dark:border-white/20 dark:bg-white/10"
>
<AnalyticsGraphic className="absolute bottom-0 h-auto w-full translate-y-[15%] [mask-image:linear-gradient(90deg,transparent,black)]" />
@@ -69,7 +78,11 @@ export function ProductContent({ domain }: { domain: string }) {
title={title}
description={description}
icon={icon}
- href={createHref(href, domain)}
+ href={createHref(
+ href,
+ domain,
+ getUtmParams({ domain, utm_content: title }),
+ )}
/>
))}
</div>
@@ -83,12 +96,11 @@ export function ProductContent({ domain }: { domain: string }) {
<ContentLinkCard
key={href}
className="-mx-2"
- href={createHref(href, domain, {
- utm_source: "Custom Domain",
- utm_medium: "Navbar",
- utm_campaign: domain,
- utm_content: title,
- })}
+ href={createHref(
+ href,
+ domain,
+ getUtmParams({ domain, utm_content: title }),
+ )}
icon={
<div className="shrink-0 rounded-[10px] border border-gray-200 bg-white/50 p-2 dark:border-white/20 dark:bg-white/10">
<Icon
@@ -106,12 +118,11 @@ export function ProductContent({ domain }: { domain: string }) {
)}
<ContentLinkCard
className="-mx-2"
- href={createHref("/customers", domain, {
- utm_source: "Custom Domain",
- utm_medium: "Navbar",
- utm_campaign: domain,
- utm_content: "Customer Stories",
- })}
+ href={createHref(
+ "/customers",
+ domain,
+ getUtmParams({ domain, utm_content: "Customer Stories" }),
+ )}
title="View all stories"
showArrow
/>
@@ -123,12 +134,11 @@ export function ProductContent({ domain }: { domain: string }) {
<ContentLinkCard
key={slug}
className="-mx-2"
- href={createHref(`/compare/${slug}`, domain, {
- utm_source: "Custom Domain",
- utm_medium: "Navbar",
- utm_campaign: domain,
- utm_content: `Dub vs. ${name}`,
- })}
+ href={createHref(
+ `/compare/${slug}`,
+ domain,
+ getUtmParams({ domain, utm_content: `Dub vs. ${name}` }),
+ )}
title={`Dub vs. ${name}`}
showArrow
/>
diff --git a/packages/ui/src/nav/content/resources-content.tsx b/packages/ui/src/nav/content/resources-content.tsx
index 1928ae4b7c..308d89cf50 100644
--- a/packages/ui/src/nav/content/resources-content.tsx
+++ b/packages/ui/src/nav/content/resources-content.tsx
@@ -3,7 +3,11 @@ import Image from "next/image";
import Link from "next/link";
import { SDKS } from "../../content";
import { DubWireframeGraphic } from "./graphics/dub-wireframe-graphic";
-import { ContentLinkCard, contentHeadingClassName } from "./shared";
+import {
+ ContentLinkCard,
+ contentHeadingClassName,
+ getUtmParams,
+} from "./shared";
const mainLinks = [
{
@@ -27,7 +31,11 @@ export function ResourcesContent({ domain }: { domain: string }) {
{mainLinks.map(({ title, description, thumbnail, href }) => (
<Link
key={title}
- href={createHref(href, domain)}
+ href={createHref(
+ href,
+ domain,
+ getUtmParams({ domain, utm_content: title }),
+ )}
className={cn(
"group relative flex flex-col overflow-hidden rounded-xl border border-neutral-100 bg-neutral-50 transition-colors duration-75 hover:bg-neutral-100/80",
"dark:border-white/20 dark:bg-white/10 dark:hover:bg-white/15",
@@ -67,12 +75,11 @@ export function ResourcesContent({ domain }: { domain: string }) {
<ContentLinkCard
key={href}
className="-mx-2"
- href={createHref(href, domain, {
- utm_source: "Custom Domain",
- utm_medium: "Navbar",
- utm_campaign: domain,
- utm_content: title,
- })}
+ href={createHref(
+ href,
+ domain,
+ getUtmParams({ domain, utm_content: title }),
+ )}
icon={
<div className="shrink-0 rounded-[10px] border border-gray-200 bg-white/50 p-1 dark:border-white/20 dark:bg-white/10">
<Icon
@@ -91,7 +98,11 @@ export function ResourcesContent({ domain }: { domain: string }) {
</div>
<div className="-mx-2 flex grow flex-col justify-end">
<Link
- href={createHref("/brand", domain)}
+ href={createHref(
+ "/brand",
+ domain,
+ getUtmParams({ domain, utm_content: "Dub Brand" }),
+ )}
className="group relative flex flex-col overflow-hidden rounded-xl bg-black transition-colors duration-75 dark:border dark:border-white/20"
>
<div className="pointer-events-none absolute inset-0">
diff --git a/packages/ui/src/nav/content/shared.tsx b/packages/ui/src/nav/content/shared.tsx
index b8314d28ed..1ddb9c93d0 100644
--- a/packages/ui/src/nav/content/shared.tsx
+++ b/packages/ui/src/nav/content/shared.tsx
@@ -9,6 +9,16 @@ export const contentHeadingClassName =
export const contentLinkCardClassName =
"group rounded-[8px] p-2 transition-colors hover:bg-neutral-50 active:bg-neutral-100 dark:hover:bg-white/[0.15] dark:active:bg-white/20";
+export const getUtmParams = ({
+ domain,
+ ...rest
+}: { domain: string } & Record<string, string>) => ({
+ utm_source: "Custom Domain",
+ utm_medium: "Navbar",
+ utm_campaign: domain,
+ ...rest,
+});
+
export function ContentLinkCard({
icon,
title,