> AI agents: this is one page of nextanalytica's docs. The full index for agents: https://nextanalytica.app/llms.txt

# Gatsby cookie consent

> Wire a cookie banner in Gatsby to analytics: count without cookies until the answer, and pass the saved answer on every page.

Updated: 2026-12-01

In Gatsby, pass the saved answer with `consent()` from `@nextanalytica/tag` when the site starts in the browser, in `gatsby-browser`, and again when the visitor clicks your banner. Until there's an answer, nextanalytica counts without cookies.

## How does it look?

```tsx title="gatsby-browser.tsx"
import { consent } from "@nextanalytica/tag";

export const onClientEntry = () => {
  const saved = localStorage.getItem("consent"); // "yes", "no" or null
  if (saved !== null) consent(saved === "yes");
};
```

## What can you ask your agent?

- "How many visitors this week came before answering the banner?"

## Next steps

- [Gatsby analytics](/docs/platforms/gatsby)
- [Cookieless counting and consent](/docs/tracking/cookieless-and-consent)

Canonical address: https://nextanalytica.app/docs/platforms/gatsby/consent
