Skip to main content
Back to all articles

Setup

Add Cookie Consent to a Next.js Website

Add your banner, connect analytics and ads, and check visitor choices on your Next.js site.

ConsentPop3 min read
Boromir meme: one does not simply paste a banner and call it done.

Add ConsentPop once, then connect tools such as Google Analytics, ads, chat and video embeds to visitor choices. If a developer manages your Next.js site, send them this guide. The steps below cover installation and the checks to run before launch.

Before you start

You need a ConsentPop account, a registered site with the right domain, and access to your Next.js source. Keep the site's own installation key. Test a staging domain only if it is allowed by your site's configuration.

Choose where the banner belongs. ConsentPop.com shows it on public pages and excludes private dashboard pages. A different site may need a different scope.

Install the widget once

Copy the current script from your dashboard or the setup page. Place it in the shared layout for the pages you want it on. Avoid adding a second copy inside each page. Next.js has its own Script component and loading strategies; choose the strategy that fits your consent initialization order.

The standard embed uses the ConsentPop CDN script and a data-api-key attribute. That installs the widget. It does not make every existing analytics, advertising, or embed script consent-aware.

Connect analytics, ads and embeds

These are services that are not needed for the website's basic features. Find where each one is added: layouts, components, plugins, and tag managers. Follow the dashboard's current integration instructions. Keep optional scripts from running before the choice permits them. If using Google tools, establish denied defaults before those tools can execute.

For our own Analytics setup, we load the Google tag only after Analytics consent and send explicit public page views. We checked client-side navigation to avoid counting the same view twice. See the live observations.

Add a way to reopen settings

The floating settings button can be hidden. If you hide it, add a button or link that calls window.ConsentPop.showPreferences() after the widget is ready. The setup page includes the button example. On ConsentPop.com, Cookie settings in the footer opens the real preferences dialog.

Verify the release

Check a first visit, reject, partial choice, accept, reload, and withdrawal. Navigate between pages without a full reload. Inspect network requests and saved records. Test a phone-sized screen and keyboard access. Do not call the installation complete just because a script URL returns 200.

A successful widget heartbeat shows that the widget reported a render on the allowed domain. It does not prove that every optional vendor is configured correctly. Use the full audit checklist before relying on the setup.

Keep legal wording, vendor details, and relevant category changes under review as the site changes.

KEEP IN THE KNOW

One less thing to figure out.

Get new cookie consent guides and practical website tips in your inbox.

PUT IT INTO PRACTICE

Give visitors a choice and keep their saved choices in one place.

Create your free banner