logoBuildBox

Analytics

  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.ts:

next.config.ts
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.ts file:

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

Last updated on

On this page

No Headings
Edit on GitHub