https://github.com/thgh/next-gtm
https://github.com/thgh/next-gtm
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/thgh/next-gtm
- Owner: thgh
- License: mit
- Created: 2023-07-12T11:39:27.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-04-29T19:47:31.000Z (about 2 years ago)
- Last Synced: 2025-02-05T14:13:36.563Z (over 1 year ago)
- Language: TypeScript
- Size: 21.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Google Tag Manager for Next.js 13 RSC
Install
```bash
yarn add @thgh/next-gtm
```
Add your GTM ID as an environment variable in `.env` or `.env.local`
```bash
NEXT_PUBLIC_GTM_ID=GTM-3X4MP7E
```
Add this snippet in `app/layout.tsx`
```tsx
import { GoogleTagManagerBody, GoogleTagManagerHead } from '@thgh/next-gtm'
export default function RootLayout({
children,
}: {
children: React.ReactNode
}) {
return (
{GoogleTagManagerHead}
{children}
{GoogleTagManagerBody}
)
}
```