Skip to content

Commit

Permalink
Merge pull request #28 from dnd-side-project/OZ-76-F-GA
Browse files Browse the repository at this point in the history
Feature : GA 태그 심기
  • Loading branch information
guesung authored Aug 25, 2023
2 parents 322686b + bdf5f2a commit 1b29492
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import './globals.css';
import '../../styles/font.css';
import '../../styles/typography.css';

import Script from 'next/script';

import { OverlayProvider } from '@/components/Overlay/OverlayProvider';
import { GA_ID } from '@/constants';
import QueryProvider from '@/provider/QueryProvider';
import RecoilContextProvider from '@/provider/RecoilContextProvider';

Expand Down Expand Up @@ -50,6 +53,7 @@ export default function RootLayout({ children }: { children: React.ReactNode })
return (
<html lang="ko">
<body className="flex min-h-[100vh] w-screen touch-none justify-center bg-slate-100 py-px">
<Gtag />
<RecoilContextProvider>
<div className="w-full max-w-440 bg-white text-primary">
<QueryProvider>
Expand All @@ -62,3 +66,20 @@ export default function RootLayout({ children }: { children: React.ReactNode })
</html>
);
}

function Gtag() {
return (
<>
<Script src={`https://www.googletagmanager.com/gtag/js?id=${GA_ID}`} />
<Script id="google-analytics">
{`
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '${GA_ID}');
`}
</Script>
</>
);
}
1 change: 1 addition & 0 deletions src/constants/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export const BASE_API_URL = process.env.NEXT_PUBLIC_API_URL;
export const BASE_SITE_URL = process.env.NEXT_PUBLIC_SITE_URL;
export const KAKAO_KEY = process.env.NEXT_PUBLIC_KAKAO_KEY;
export const GA_ID = process.env.NEXT_PUBLIC_GA_ID;

0 comments on commit 1b29492

Please sign in to comment.