삽입하고 싶은 <script/> 태그
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=AW-11544522551"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'AW-11544522551');
</script>
Next.js에서 삽입 예시
import Script from "next/script";
export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<html lang="ko">
<head>
{/* Google Ads 태그 추가 */}
<Script async src="https://www.googletagmanager.com/gtag/js?id=AW-11544522551" />
<Script id="google-ads-tag">
{`
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'AW-11544522551');
`}
</Script>
</head>
<body>
{children}
</body>
</html>
);
}
'프론트엔드 > Next.js' 카테고리의 다른 글
[Next.js] Next.js SEO 관련 공식문서 (0) | 2025.01.09 |
---|---|
[Next.js] Next.js 구글 검색 엔진 최적화(SEO) 가이드 (0) | 2025.01.08 |
[Next.js] Next.js 네이버 웹마스터 검색 엔진 최적화(SEO) 가이드 (0) | 2025.01.08 |
[Next.js] Next.js 15버전 GA 태그 추가 방법 (0) | 2025.01.06 |
[Next.js] Next.js 15버전 PWA 적용 방법 (0) | 2025.01.06 |