next-ga4
v0.1.0
Published
Google Analytics 4 for Next.js
Downloads
4
Maintainers
Readme
next-ga4
Google Analytics 4 for Next.js
Install
npm install next-ga4or
yarn add next-ga4Usage
Add <NextGA /> to _app.tsx.
import type { AppProps } from 'next/app'
import { NextGA } from 'next-ga4'
const App = ({ Component, pageProps }: AppProps) => {
return (
<>
<NextGA measurementId="G-XXXXXXXXXX" />
<Component {...pageProps} />
</>
)
}
export default AppOptions
| Property | Description | Type | Required | Default |
| :--------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :-------- | :------- | :---------- |
| measurementId | Measurement ID. | string | Yes | |
| initialConsentParams | Parameters for consent on initial execute. | object | No | undefined |
| initialSetParams | Parameters for set on initial execute. | object | No | undefined |
| initialConfigParams | Parameters for config on initial execute. | object | No | undefined |
| isListenRouterEvents | Whether to detect pushState, popState, and replaceState and send page_viewIf true, disable Page changes based on browser history events in Enhanced measurement. | boolean | No | true |
Hints
How do i debug?
- Add Google Analytics Debugger to Google Chrome and enable it
- Click Configure -> DebugView in the left navigation
- Reload the website you want to debug
More details: [GA4] Monitor events in debug mode
References
Author
License
MIT
