Skip to content

Commit 2976835

Browse files
committed
feat(ads): track Google Ads
1 parent fb04375 commit 2976835

File tree

4 files changed

+47
-0
lines changed

4 files changed

+47
-0
lines changed

app/layout.tsx

+7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
import { GoogleTagManager } from "@next/third-parties/google";
12
import clsx from "clsx";
23
import { Metadata } from "next";
34
import PlausibleProvider from "next-plausible";
45
import { Inter } from "next/font/google";
56
import localFont from "next/font/local";
7+
import { Suspense } from "react";
68

79
import { TooltipProvider } from "@/components/Tooltip";
810
import "@/styles/globals.css";
@@ -11,6 +13,7 @@ import "@/styles/highlight-js-github-dark.min.css";
1113
import { ClientProviders } from "./client-providers";
1214
import { AppFooter } from "./footer";
1315
import { AppNavbar } from "./navbar";
16+
import { NavigationEvents } from "./navigation-events";
1417

1518
// Fonts
1619
const inter = Inter({ subsets: ["latin"], variable: "--font-inter" });
@@ -57,6 +60,7 @@ export default function RootLayout({
5760
className={clsx(inter.variable, calSans.variable, "antialiased")}
5861
suppressHydrationWarning
5962
>
63+
<GoogleTagManager gtmId="AW-847457408" />
6064
<head>
6165
<PlausibleProvider domain="argos-ci.com" />
6266
</head>
@@ -70,6 +74,9 @@ export default function RootLayout({
7074
</div>
7175
</TooltipProvider>
7276
</ClientProviders>
77+
<Suspense fallback={null}>
78+
<NavigationEvents />
79+
</Suspense>
7380
</body>
7481
</html>
7582
);

app/navigation-events.tsx

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
"use client";
2+
3+
import { sendGTMEvent } from "@next/third-parties/google";
4+
import { usePathname, useSearchParams } from "next/navigation";
5+
import { useEffect } from "react";
6+
7+
export function NavigationEvents() {
8+
const pathname = usePathname();
9+
const searchParams = useSearchParams();
10+
11+
useEffect(() => {
12+
sendGTMEvent({
13+
event: "conversion",
14+
send_to: "AW-847457408/e6s6CMGhwe8YEIDZjJQD",
15+
});
16+
}, [pathname, searchParams]);
17+
18+
return null;
19+
}

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"@mdx-js/loader": "^3.0.1",
1616
"@mdx-js/react": "^3.0.1",
1717
"@next/mdx": "^14.2.3",
18+
"@next/third-parties": "^14.2.3",
1819
"@openstatus/react": "^0.0.3",
1920
"@radix-ui/react-accordion": "^1.1.2",
2021
"@radix-ui/react-dialog": "^1.0.5",

pnpm-lock.yaml

+20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)