NextJS | Plausible.io integration | Custom Document | Head

PHOTO EMBED

Sun Jun 19 2022 13:25:22 GMT+0000 (Coordinated Universal Time)

Saved by @DimitarStoev #nextjs #javascript #plausible #analytics

import Document, {Html, Head, Main, NextScript} from 'next/document'

class MyDocument extends Document {
    render() {
        return (
            <Html>
                <Head>
                    <base href="/"></base>
                    <script async defer data-domain="<your-domain.com>" src="https://plausible.io/js/plausible.js"></script>

                </Head>
                <body>
                <Main/>
                <NextScript/>
                </body>
            </Html>
        )
    }
}

export default MyDocument
content_copyCOPY

Plausible.io Analytics integration to the custom Document of NextJS HEAD