Setup
1 2 3 4 5 6 <script defer data-domain="YOUR_DOMAIN" data-api="/plausible/api/event" src="/plausible/js/script.js" ></script>
(optional) Some adblockers block Plausible. To fix this, proxy the script through the nextjs /api. First add this to next.config.js:
Then replace the Plausible script in the the main layout.js file:
1 2 3 4 5 6 <script defer data-domain="YOUR_DOMAIN" data-api="/plausible/api/event" src="/plausible/js/script.js" ></script>
I use Plausible for traffic analytics & custom events. If you want to use another tool, remove the Plausible script in the layout.js file.