FeaturesAnalytics

Setup

  • Create a new site on Plausible
  • (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

    1async rewrites() {
    2    return [
    3      {
    4        source: "/plausible/js/script.js",
    5        destination: "https://plausible.io/js/script.js",
    6      },
    7      {
    8        source: "/plausible/api/event",
    9        destination: "https://plausible.io/api/event",
    10      },
    11    ];
    12}
    Then replace the Plausible script in the _document.js file with this:

    _document.js

    1<script
    2    defer
    3    data-domain="YOUR_DOMAIN"
    4    data-api="/plausible/api/event"
    5    src="/plausible/js/script.js"
    6  ></script>

I use Plausible for traffic analytics & custom events. If you want to use another tool, remove the Plausible script tag in the _document.js file.