All articles

How to read OneTrust's OptanonConsent cookie

OneTrust writes every choice into one cookie. Decode it and you can answer "what did this visitor agree to?" in seconds.

Naini Anjaneyulu, 5 December 2026

"The pixel didn't fire for me." Before you open Tag Manager, find out what that person actually agreed to. On any site running OneTrust, the answer is sitting in a cookie.

Find it

Press F12, open the Application tab and look under Cookies for your domain. Two cookies start with Optanon:

CookieWhat it holds
OptanonConsentThe visitor's choices, plus when and where they were made
OptanonAlertBoxClosedThe date the visitor closed the banner. While it exists, the banner stays hidden.

Decode the choices

The value of OptanonConsent is long and URL-encoded. Paste this into the Console to make it readable:

decodeURIComponent(document.cookie.match(/OptanonConsent=([^;]+)/)[1])

Look for the part that starts with groups=:

groups=C0001:1,C0002:1,C0003:0,C0004:0

1 means allowed and 0 means refused. This visitor said yes to strictly necessary and performance cookies, and no to functional and targeting. On a default setup, that's analytics on and advertising off, so a missing Meta Pixel is the system working.

Two other fields are worth knowing. datestamp is when the choice was saved. geolocation shows the country and, in the US, the state OneTrust used to pick its rule, for example US;CA.

Three questions it answers

First, what the visitor allowed: the groups value.

Second, which rule they got. A colleague in Hyderabad testing through a VPN in Germany will get the European opt-in rule and see far fewer tags than they expect. The geolocation field tells you which rule OneTrust applied.

Third, whether they answered at all. No OptanonAlertBoxClosed cookie means the banner was never closed. In Europe that means the defaults still apply, so almost nothing will fire.

Cookie or variable?

The cookie is the saved choice. OnetrustActiveGroups is what OneTrust is using on the page right now. They should agree once OneTrust has loaded. If GTM Preview shows a tag reading an empty or different value, the tag most likely ran before OneTrust loaded, and its trigger needs to wait for the OneTrustLoaded event.

Three Console shortcuts

OneTrust.IsAlertBoxClosed()     // has the visitor answered?
OneTrust.getGeolocationData()   // which country and state OneTrust sees
OneTrust.ToggleInfoDisplay()    // open the settings panel

Next time someone reports a tag that didn't fire, ask them to run the decode line and paste the result. It takes thirty seconds, and often saves you a screen-share.

More articles

Does your site honour Global Privacy Control?

Some browsers tell every site "don't sell or share my data". In California that signal counts as an opt-out. Here's how to check that your site listens.

5 minute read

Opt-in for Europe, opt-out for the US: one OneTrust setup for both

European law wants permission before tracking. US state laws want a clear way to refuse. Geolocation rules let one site do both.

7 minute read

How OneTrust tells Google Tag Manager what a visitor chose

One variable and two events carry every consent choice from OneTrust into GTM. Here's how to read them and build triggers that don't miss.

6 minute read

Mapping OneTrust categories to Google Consent Mode

OneTrust thinks in cookie categories, Google thinks in seven consent types. A mapping that works, and the one setting that causes double defaults.

7 minute read

Consent checks or triggers? Two ways to make a tag wait in GTM

Google Tag Manager can hold a tag back with consent settings or with trigger conditions. They behave differently when a visitor changes their mind.

6 minute read

Does your cookie banner block anything?

A banner can look right and still let every tag fire. Four checks, all in your own browser.

5 minute read

How to check your dataLayer in five minutes

A quick routine, using only your browser, to see whether your site is sending the data your tags depend on.

6 minute read

Dashboards that answer one question well

Why most dashboards get ignored, and a simple way to design ones that people open every week.

7 minute read

Why tags break after a site update

The usual reasons tracking fails after a release, and a short checklist to stop it happening to you.

6 minute read

Can you trust your data?

Tell me what you track, and what you ask visitors before you track it.

Start a project