Add Google Analytics to your Next.js App in 60 seconds.
npm install next-google-analytics> Add Google Analytics to your Next.js App in 60 seconds.
Set environment variable NEXT_PUBLIC_GA_MEASUREMENT_ID to your Google Analytics tracking id.
```
yarn add next-google-analytics
`diff
+ import * as GoogleAnalytics from 'next-google-analytics';
const App = (...) => {
+ GoogleAnalytics.useAppInit();
...
};
+ export { reportWebVitals } from 'next-google-analytics';
`
`diff
+ import * as GoogleAnalytics from 'next-google-analytics';