Anaytics — Ship Fast ⚡️

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

    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 _document.js file with this:

    _document.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 tag in the _document.js file.