Blog
August 14, 2026
3 mins
Product Updates
Integrations

Build Smarter Privacy UX With Consentmo’s Storefront JavaScript API

Consentmo’s Storefront JavaScript API lets themes, custom storefronts, and Hydrogen shops react to real visitor consent and accessibility choices. Enable the script once, then use window.Consentmo for flexible privacy UX.
Consentmo Storefront JavaScript API for Shopify.

Your cookie banner and accessibility widget already handle the heavy lifting. Sometimes your storefront needs to go one step further: load a script only after marketing consent, open cookie preferences from a footer link, or tie a custom button to the accessibility panel.

That is what the Consentmo Storefront JavaScript API is for. Once Consentmo runs on the page (via the app embed or the Hydrogen script), window.Consentmo is available and your theme or headless storefront can work with live consent and accessibility state.

You do not need the API for Consentmo to work. The banner, preference center, and accessibility widget run on their own. Use the API when you want deeper control and cleaner custom integrations.

What you get

With the script active, developers can:

  • Read consent in real time, see whether analytics, marketing, preferences, or necessary categories are allowed
  • React when choices change, listen for updates and load or pause tools without a page refresh
  • Open preferences from your own UI, footer “Cookie preferences,” privacy page buttons, or custom nav items
  • Pass consent from advanced flows, when a custom interface collects choice and Consentmo should stay the source of truth
  • Control the Web Accessibility widget, open, close, or toggle the panel; check what adjustments a visitor enabled; show or hide the floating control when it helps the layout
Consentmo JavaScript API consent methods reference.

The in-app reference lists properties, methods, events, cookie helpers, and accessibility controls in one place.

Benefits for merchants and teams

Privacy-safe custom features

Only run marketing pixels, chat widgets, or personalization after the matching category is allowed. Fewer accidental loads before consent.

Consistent experience across your brand UI

Visitors stay inside your theme design while Consentmo still manages the legal choice, records, and banner logic.

Faster agency and theme work

One stable window.Consentmo surface instead of scraping the DOM or reinventing consent storage.

Better accessibility journeys

Link your own “Accessibility” control to Consentmo’s panel, or adapt layout when visitors enable high contrast, link highlighting, and similar adjustments.

Hydrogen and headless ready

The same idea applies on custom storefronts when Consentmo is installed with the Hydrogen / headless setup and Customer Privacy wiring.

Practical use cases

  1. Footer cookie link, “Manage cookies” opens Consentmo preferences instead of a dead page.
  2. Conditional analytics, a custom script checks analyticsAllowed() (or full consent) before initializing.
  3. Campaign landing pages, listen for consent updates and enable remarketing tags the moment the shopper accepts marketing.
  4. Brand accessibility button, your header icon calls the accessibility open/toggle methods so the widget matches your design system.
  5. Agency-built privacy hub, a custom privacy center page reads status, explains choices in your copy, and still relies on Consentmo for the real preference dialog.
  6. Headless Shopify, Hydrogen (or similar) storefronts keep consent logic aligned with the rest of the stack.
Consentmo JavaScript API consent status example.

Who it is for

  • Theme developers and Shopify Plus teams
  • Merchants with custom scripts or third-party tools that must respect consent
  • Agencies shipping tailored privacy or accessibility UX
  • Hydrogen and other headless implementations

If you only need a compliant banner and standard preference center, install Consentmo and skip the API. Reach for it when your storefront needs to talk to consent and accessibility state.

How it works

  1. Enable Consentmo on the storefront (app embed on Online Store 2.0 themes, or the documented Hydrogen / headless script).
  2. Confirm window.Consentmo is present in the browser.
  3. Read consent, subscribe to events, open dialogs, or use window.Consentmo.accessibility as needed.
  4. Keep visitor choice accurate whenever you update consent from a custom UI.

Exact method names, return shapes, and event constants live in the full reference. This article stays at the product level on purpose.

Read the full technical details

For method lists, code samples, document events, cookie helpers, and the Web Accessibility API:

  1. Open the Consentmo GDPR app in Shopify
  2. Go to Settings → Storefront JavaScript API
  3. Switch between Description and Code reference as needed
Open the full API guide →

Get started

Already on Consentmo? Turn on the embed (or Hydrogen script), open the API reference in Settings, and wire one high-value action first, such as a footer preferences link or a consent-gated script.

New to Consentmo? Install Consentmo on Shopify, configure your regions and banner, then add the Storefront JavaScript API where your theme or headless storefront needs custom behavior.

Questions? Our team is available in-app live chat or at support@consentmo.com.

Mariya Petrova
Growth & Product Marketing
With over 7 years of experience in advertising across agencies and e-commerce brands, Mariya has made marketing her core element. Today, she supports Consentmo users by guiding them through the realms of compliance, Shopify, and all things marketing.