# NextJS

&#x20;Here are the steps for users to add your web analytics script to their Next.js project :&#x20;

### Steps to Add Script to a Next.js Project

1. Go to your SiteBehaviour Organisation's page and click on the **Settings button** for your site.
2. Go to the Tracking code tab.
3. Click on **Copy** to copy the Tracking Code to your clipboard.
4. In your Next.js project directory, find the `pages` folder. This folder contains the main entry point for your application, such as `_app.js` or `_app.tsx`.
5. Open the `_app.js` (or `_app.tsx` if you're using TypeScript) file in the `pages` folder.
6. At the top of your `_app.js` or `_app.tsx` file, import the `Head` component from `next/head`.

```
import Head from 'next/head';
```

&#x20;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;

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sitebehaviour.com/guides-and-integrations/nextjs.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
