NextJS
Here are the steps for users to add your web analytics script to their Next.js project :
Steps to Add Script to a Next.js Project
Go to your SiteBehaviour Organisation's page and click on the Settings button for your site.
Go to the Tracking code tab.
Click on Copy to copy the Tracking Code to your clipboard.
In your Next.js project directory, find the
pagesfolder. This folder contains the main entry point for your application, such as_app.jsor_app.tsx.Open the
_app.js(or_app.tsxif you're using TypeScript) file in thepagesfolder.At the top of your
_app.jsor_app.tsxfile, import theHeadcomponent fromnext/head.
import Head from 'next/head'; 7 . Add the Head component to your custom App component and place your SiteBehaviour script inside it.
// _app.js
import Head from 'next/head';
import '../styles/globals.css';
function MyApp({ Component, pageProps }) {
return (
<>
<Head>
<script>
{`
// Your sitebehaviour tracking script here
`}
</script>
</Head>
<Component {...pageProps} />
</>
);
}
export default MyApp;
Last updated