Skip to content

Commit

Permalink
chore: Add Google tag (gtag.js) for analytics tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriel-logan committed Jun 14, 2024
1 parent 3d6ede6 commit a00c3c6
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions docs/src/app/[locale]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import "../globals.css";
import { Analytics } from "@vercel/analytics/react";
import { SpeedInsights } from "@vercel/speed-insights/next";
import type { Metadata } from "next";
import Script from "next/script";

import Adsense from "@/components/Adsense";
import Footer from "@/components/Footer";
Expand Down Expand Up @@ -75,6 +76,10 @@ export async function generateMetadata(): Promise<Metadata> {

verification: {
google: process.env.NEXT_PUBLIC_GOOGLE_SEARCH_CONSOLE_API_KEY,
other: {
"google-adsense-account": process.env
.NEXT_PUBLIC_GOOGLE_ADSENSE_CLIENT_ID as string,
},
},

appleWebApp: {
Expand Down Expand Up @@ -134,15 +139,25 @@ export default async function RootLayout({
return (
<html lang={locale}>
<head>
<meta
name="google-adsense-account"
content={process.env.NEXT_PUBLIC_GOOGLE_ADSENSE_CLIENT_ID}
/>
<Adsense
GOOGLE_ADSENSE_CLIENT_ID={
process.env.NEXT_PUBLIC_GOOGLE_ADSENSE_CLIENT_ID
}
/>
{/**<!-- Google tag (gtag.js) --> */}
<Script
async
src="https://www.googletagmanager.com/gtag/js?id=AW-11180158373"
/>
<Script id="googleTag">
{`
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'AW-11180158373');
`}
</Script>
</head>
<body className={inter.className}>
<I18nProviderClient locale={locale}>
Expand Down

0 comments on commit a00c3c6

Please sign in to comment.