Skip to content

Commit b0db371

Browse files
docs - ga4
1 parent 084e31f commit b0db371

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

docs-v2/components/GA4.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import Script from "next/script";
2+
3+
export default function GA4() {
4+
return (
5+
<>
6+
<Script
7+
src="https://www.googletagmanager.com/gtag/js?id=AW-770996949"
8+
strategy="lazyOnload"
9+
/>
10+
11+
<Script id="gtag-init" strategy="lazyOnload">
12+
{
13+
`
14+
window.dataLayer = window.dataLayer || [];
15+
function gtag(){dataLayer.push(arguments);}
16+
gtag('js', new Date());
17+
18+
gtag('config', 'AW-770996949');
19+
`
20+
}
21+
</Script>
22+
</>
23+
);
24+
}

docs-v2/pages/_app.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Analytics } from "@vercel/analytics/next";
44
import { useRouter } from "next/router";
55

66
import CR from "@/components/CR";
7+
import GA4 from "@/components/GA4";
78
import RB2B from "@/components/RB2B";
89
import Vector from "@/components/Vector";
910
import VectorConnect from "@/components/VectorConnect";
@@ -15,7 +16,12 @@ export default function MyApp({
1516

1617
let script = null;
1718
if (router.pathname === "/") {
18-
script = <Vector />;
19+
script = (
20+
<>
21+
<GA4 />
22+
<Vector />
23+
</>
24+
);
1925
} else if (router.pathname.startsWith("/connect")) {
2026
script = (
2127
<>

0 commit comments

Comments
 (0)