FeaturesAnalytics

Analytics

Setup

  1. Create a new site on Plausible

  2. (optional) Some adblockers block Plausible. To fix this, proxy the script through the nextjs /api.
    First add this to next.config.js:

next.config.js
async rewrites() {
    return [
      {
        source: "/plausible/js/script.js",
        destination: "https://plausible.io/js/script.js",
      },
      {
        source: "/plausible/api/event",
        destination: "https://plausible.io/api/event",
      },
    ];
}

Then replace the Plausible script in the the main layout.js file:

layout.js
<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.