next-goatcounter
next-goatcounter is a plugin that makes integrating GoatCounter Analytics into you NextJS project easy.
Pull Requests are very welcome.
Feel like supporting this free plugin?
Setup
First, install it:
npm install next-goatcounter
or
yarn add next-goatcounter
Now, in app/layout.js
import { GCScript } from "next-goatcounter";
and in return
<body>
<GCScript siteUrl={"https://site.goatcounter.com/count"} />
{
children
}
</body>
Note: GCScript
supports scriptSrc
parameter to specify self hosted count.js location
Usage
To send custom events to GoatCounter,
first
import { GCEvent } from "next-goatcounter";
then use GCEvent
like this
GCEvent(path, title);