9e5116975d
taken from google analytic's page: "_On July 1, 2023, this property will stop processing data. Starting in March 2023, for continued website measurement, migrate your original property settings to a Google Analytics 4 (GA4) property, or they'll be copied for you to an existing GA4 property, reusing existing site tags._" The package 'react-ga' doesn't support GA4, so i updated the package to 'react-ga4', the example continues primarily the same, the only differences is that specifying 'pageview' is now required instead of just setting the location of the pageview and the expection() function doesn't exist in this package. required changes are welcomed Co-authored-by: Steven <229881+styfle@users.noreply.github.com> |
||
---|---|---|
.. | ||
pages | ||
utils | ||
.gitignore | ||
package.json | ||
README.md |
React-GA4 example
As of May 2023, react-ga uses Universal Analytics which will stop processing new data starting July 2023. Until this is fixed, this example has been updated to use react-ga4 instead.
This example shows the most basic way to use react-ga4 using custom App
component with NextJs. Modify Tracking ID
in utils/analytics.js
file for testing this example.
Deploy your own
Deploy the example using Vercel:
How to use
Execute create-next-app
with npm, Yarn, or pnpm to bootstrap the example:
npx create-next-app --example with-react-ga4 with-react-ga-app
yarn create next-app --example with-react-ga4 with-react-ga-app
pnpm create next-app --example with-react-ga4 with-react-ga-app
Deploy it to the cloud with Vercel (Documentation).