4lejandrito / next-plausible

Simple integration for https://nextjs.org and https://plausible.io analytics
https://next-plausible.vercel.app
MIT License
603 stars 33 forks source link

PlausibleProvider with Next js 13.4.12 #103

Open 4lejandrito opened 1 year ago

4lejandrito commented 1 year ago

Discussed in https://github.com/4lejandrito/next-plausible/discussions/100

Originally posted by **jamezening** August 12, 2023 I am having difficulty getting PlausibleProvider to work with Next js 13.4.12. As shown in the documentation I have added the provider in > app/layout.tsx ```
{children}
``` I am not getting any event from local host or when deployed. Any tips would be appreciated.
jedwards1230 commented 1 year ago

Do you have any extensions that may be blocking the request to Plausible? I think UBlock Origin (or something similar) was blocking my plausible requests from resolving.

If this is the issue, you can unblock your domain, or you can check out the plausible proxy in this repo. The proxy redirects the request back to your server, then off to plausible. This way it looks like a normal transaction with your site instead of tracking.

Peracek commented 8 months ago

@4lejandrito any chance you have badly set NODE_ENV variable? This is the condition for the tracking being enabled.

enabled = process.env.NODE_ENV === 'production' &&
      (!process.env.NEXT_PUBLIC_VERCEL_ENV ||
        process.env.NEXT_PUBLIC_VERCEL_ENV === 'production')