How to add a cookie consent banner
TeleportHQ has a built-in Cookie Consent element: a bar at the bottom of the page that reads "We use cookies to measure visits to this site.", with a link to your terms page and the Accept and Decline buttons. On your published site, Google Analytics and Google Tag Manager wait until the visitor clicks Accept. To add the banner, open Elements, find Cookie Consent in the Interactive group and click it, or drag it onto a page. It works on every project: adding it doesn't turn a website into a web app. If you need cookie categories, use a banner from a cookie consent tool instead.
Before you start
- You need a role that can edit components.
- The TeleportHQ banner makes Google Analytics and Google Tag Manager wait for Accept (Google's consent mode). It doesn't hold back other scripts, like ad pixels pasted into custom code. If those need to wait too, or your site needs cookie categories, use a consent tool (see the last section).
- This article explains how the banner works, not which banner the law requires for your site. Ask a legal advisor.
Add the TeleportHQ Cookie Consent banner
- Open the page where the banner should appear.
- In the left sidebar, click Elements. The Primitives tab opens.
- Scroll to the Interactive group, or type
Cookiein the search box.
- Click Cookie Consent, or drag it onto the page. The banner is added at the bottom of the page and selected.
- Repeat for every page where visitors can land. Add the banner once per page.
- Publish your site. See How to publish your site.
TeleportHQ also links the banner to a legal page, and the link shows that page's name, for example Terms & Conditions. It uses an existing page named Terms & Conditions, Terms and Conditions, Privacy Policy, Terms of Service, Legal or Privacy. If there's none, it creates a Terms & Conditions page with your navigation, footer and template legal text. Review and edit that text before you publish.
What visitors see
On your published TeleportHQ site, the banner reads "We use cookies to measure visits to this site.", followed by a link named after your legal page, and the Accept and Decline buttons. The banner shows until the visitor clicks one of them.
When a visitor clicks Accept:
- the banner hides and stays hidden on their next visits,
- their choice is saved in the browser's local storage (not in a cookie),
- TeleportHQ visitor analytics starts recognizing them as a returning visitor,
- Google Analytics and Google Tag Manager, if your site uses them, switch on at once, on the same page.
When a visitor clicks Decline:
- the banner hides and stays hidden on their next visits, and their refusal is saved in the browser's local storage,
- TeleportHQ visitor analytics still counts their visits anonymously, without a saved ID, like a visitor who doesn't answer,
- Google Analytics and Google Tag Manager stay in consent mode and set no cookies.
See Does TeleportHQ analytics use cookies?.
On a site with several languages, the other languages show the banner's message in your main language until it's translated, for example with Translate everything missing in Manage Content. See How to review and edit translations.
Banners you added before the Decline button
A TeleportHQ Cookie Consent banner added before the Decline button existed is updated the first time you open the project in the editor:
- If its message is still the earlier default, for example "By continuing to visit this site you agree to our terms and conditions", it becomes "We use cookies to measure visits to this site.", and its link takes your legal page's name. A message you wrote yourself stays.
- It gets a Decline button next to Accept, unless you changed the banner's workflows.
- On a site with several languages, the other languages get the new message in your main language, still to translate. In Manage Content it's marked Still in your main language, for example Still in English, and listed under Untranslated only.
The update is one step you can undo. Publish your site so your visitors get the updated banner.
Edit the banner in the editor
The TeleportHQ Cookie Consent banner only shows to visitors who haven't answered yet, so on the canvas it's hidden by default, out of your design's way. It shows right after you add it. The next time you open the project, it's hidden again. To show it:
- At the bottom of the canvas, click the pill that counts hidden elements, for example 1 hidden element. The Hidden Elements list opens.
- Next to Cookie Consent, click Show. To hide it again, click Hide.
You can also click See all conditionally rendered nodes next to the pill, to show every hidden element at once. Then select the banner's text, its Accept button or its Decline button and change them like any other element. See How to show or hide elements based on a condition.
Check that it worked
Open your published site in a private browser window. The banner shows at the bottom. Click Accept or Decline, then reload the page. The banner doesn't come back. To see it again, open the site in a new private window.
Troubleshooting
"Cookie consent can only be placed at the root level. It has been added to the root of the page/component." You dropped the banner inside another element. TeleportHQ moved it to the page level, where it belongs. Nothing else to do.
"Your current role does not have permission to edit components" Ask a workspace owner or admin for a role that can edit.
I can't see the banner in the editor anymore It's hidden on the canvas until you show it. Click the hidden elements pill at the bottom of the canvas, then Show next to Cookie Consent. It always shows on the published site to visitors who haven't answered.
"Could not save your cookie preferences. Please try again." A visitor sees this when their click on Accept or Decline couldn't be saved, for example because their browser blocks site storage. The banner stays visible for that visitor. Ask them to try again or allow site data for your site.
Where TeleportHQ adds the banner automatically
When AI builds a TeleportHQ web app, the banner is added for you to its AI-generated pages, sign-in pages, store pages and Terms & Conditions page. It's never added by itself to a website, to admin panel pages or to blank pages you create. Add it to those pages by hand if they're public.
Use a banner from a cookie consent tool instead
Use a third-party consent tool when you need cookie categories, or when ad pixels and other code you paste into custom code must wait until visitors agree.
- Create a banner in your consent tool and copy its install code.
- In the editor, click the Project settings cog at the bottom of the left sidebar.
- Under Data & code, click Custom code.
- Click Body, or Head if the tool asks for the head, and paste the code. It saves itself: there's no Save button.
- Publish your site.
TeleportHQ visitor analytics only counts returning visitors if the tool also saves cookieConsent with the value accepted in the browser's local storage when a visitor accepts. Most tools don't do this on their own. The Google consent mode that TeleportHQ adds only comes with the TeleportHQ banner: with another tool, set up Google's consent in that tool or in Google Tag Manager. See How to add code to every page (head and body).
Good to know
- Google waits on every page. With the TeleportHQ banner on your site, Google Analytics and Google Tag Manager wait for Accept on all its pages. A visitor who lands on a page without the banner can't accept there, so add it to every page visitors can land on.
- Code downloads. The banner works on your published site and in the Next.js code download. The other code downloads, such as HTML, leave it without its behaviour, so its buttons don't hide it. The download window tells you so when you pick one of them.