Skip to content

Commit

Permalink
Merge branch 'main' into fix-issue-6
Browse files Browse the repository at this point in the history
  • Loading branch information
ezhillragesh authored Jan 8, 2024
2 parents 603cea8 + 5875f4a commit b22b01a
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 15 deletions.
27 changes: 12 additions & 15 deletions app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import './globals.css';
import Navbar from '@/comps/navbar';
import Footer from '@/comps/Footer';
import Script from 'next/script';

import Head from 'next/head';
import GoogleAnalytics from '@/comps/GoogleAnalytics';
const inter = Poppins({
subsets: ['latin'],
display: 'swap',
Expand All @@ -25,30 +26,26 @@ export default function RootLayout({
}) {
return (
<html lang="en" className="dark:bg-[#09090B]">
<Head>
<link rel="icon" type="image/x-icon" href="favicon.svg" />
<link rel="preconnect" href="https://fonts.gstatic.com" />
<link rel="preconnect" href="https://api.github.com" />


<Script
strategy="lazyOnload"
src={`https://www.googletagmanager.com/gtag/js?id=${process.env.NEXT_PUBLIC_GOOGLE_ANALYTICS}`}
/>
</Head>


<Script strategy="lazyOnload">
{`
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '${process.env.NEXT_PUBLIC_GOOGLE_ANALYTICS}', {
page_path: window.location.pathname,
});
`}
</Script>


<body className={inter.className}>

<Navbar />
{children}
<Analytics />
{process.env.NEXT_PUBLIC_GOOGLE_ANALYTICS ? (
<GoogleAnalytics ga_id=
{process.env.NEXT_PUBLIC_GOOGLE_ANALYTICS} />
) : null}
<div className=" my-14"></div>
<Footer />
</body>
Expand Down
24 changes: 24 additions & 0 deletions comps/GoogleAnalytics.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import Script from "next/script";

const GoogleAnalytics = ({ ga_id }: { ga_id: string }) => (
<>
<Script
async
src={`https://www.googletagmanager.com/gtag/js?
id=${ga_id}`}
></Script>
<Script
id="google-analytics"
dangerouslySetInnerHTML={{
__html: `
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '${ga_id}');
`,
}}
></Script>
</>
);
export default GoogleAnalytics;
13 changes: 13 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
"lint": "next lint"
},
"dependencies": {

"@bradgarropy/next-google-analytics": "^1.0.2",
"@next/font": "^14.0.4",
"@radix-ui/react-accordion": "^1.1.2",
"@radix-ui/react-dialog": "^1.0.5",
"@radix-ui/react-icons": "^1.3.0",
Expand Down

0 comments on commit b22b01a

Please sign in to comment.