In this setup we will setup Google Analytics with Remix.
Open this example on CodeSandbox:
This example shows how to use Google analytics with Remix.
- Copy
.env.example
to.env
- Configure your Google Analytics ID in the
.env
file (read from theentry.server.tsx
file) - Run the project
Check app/root.tsx where page tracking code is added. For tracking events check app/routes/contact.tsx file.
The Google Analytics tag is disabled in "development", you can enable it during your test, but make sure to only enable tracking in production.