Javascript API (New Version)
Overview
The Pandectes JavaScript API allows you to interact with the consent banner programmatically from your store's theme or custom scripts. Without writing complex code, understanding what the API offers helps you know what is possible and when to ask a developer to implement it for you.
This feature is available on the New Banner and is accessible from Settings → JavaScript API.
What can you do with the JavaScript API?
Read the visitor's current consent state
The API lets your store always know, in real time, what a visitor has consented to. You can check:
- Whether a visitor has allowed analytics tracking (e.g. Google Analytics, Microsoft Clarity)
- Whether a visitor has allowed marketing cookies (e.g. Facebook Pixel, TikTok)
- Whether a visitor has allowed preferences/functionality cookies
- The full consent decision of the visitor as a single object
This is useful when you want other parts of your store to behave differently depending on what the visitor has agreed to.
Control the consent dialog
The API gives you the ability to open or close the consent banner dialog from any action on your store. For example, a button in the footer, a link in a privacy policy page, or a custom "Cookie settings" option in your menu. This works alongside the built-in menu link feature but gives developers more flexibility to trigger it from any element on the page.
Set or update consent programmatically
In advanced scenarios, your store can set a visitor's consent decision directly. For example, when a visitor makes a consent choice through a custom UI you have built, or when consent is collected through a different mechanism and needs to be passed to Pandectes to apply.
Change the language of the banner
The API allows the language of the consent dialog to be switched dynamically. If your store serves visitors in multiple languages and detects their preference, the banner can be shown in the correct language without relying solely on the browser's default.
React to consent events
The API can notify your store the moment something consent-related happens, such as:
- When the banner has fully loaded and is ready
- When the consent dialog is opened by the visitor
- When the consent dialog is closed
- When the visitor changes or submits their consent preferences
This means you can build flows that react instantly to a visitor's choice. For example, loading a tracking script the moment consent is given, without needing to refresh the page.
Who is this for?
The JavaScript API is intended for merchants with a developer or for those using a custom storefront. You do not need to use or understand the API for the banner to work. It operates fully on its own out of the box. However, if you want deeper integration between the consent banner and the rest of your store's behaviour, the API is the right tool.
Getting started
To explore the API and see the full reference, navigate to Settings → JavaScript API inside the Pandectes app. The page includes the complete list of available properties, functions, and events with descriptions. If you need help implementing a specific use case, feel free to reach out to our support team.
Updated on: 17/04/2026
Thank you!
