Skip to content

Commit

Permalink
Merge pull request #14 from Funssion-SWM/develop
Browse files Browse the repository at this point in the history
Chore: google analytics 추가
  • Loading branch information
dongree authored Aug 14, 2023
2 parents 2f45001 + b553cd0 commit 4aef932
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Providers from './providers';
import { pretendard } from '@/styles/fonts';
import ModalProvider from '@/context/ModalProvider';
import Modal from '@/components/Modal';
import GoogleAnalytics from '@/components/GoogleAnalytics';

export const metadata = {
title: 'Inforum',
Expand All @@ -17,6 +18,7 @@ export default async function RootLayout({
}) {
return (
<html lang="en" className={pretendard.className}>
<GoogleAnalytics />
<body className="flex flex-col">
<ModalProvider>
<Providers>{children}</Providers>
Expand Down
24 changes: 24 additions & 0 deletions src/components/GoogleAnalytics.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
'use client';

import Script from 'next/script';

const GA_MEASUREMENT_ID = 'G-1VXEE7839P';

export default function GoogleAnalytics() {
return (
<>
<Script
src={`https://www.googletagmanager.com/gtag/js?id=${GA_MEASUREMENT_ID}`}
/>
<Script id="google-analytics">
{`
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '${GA_MEASUREMENT_ID}');
`}
</Script>
</>
);
}

0 comments on commit 4aef932

Please sign in to comment.