Debugging
Open your browser's developer tools and work through the checks below to confirm the script is running and behaving as expected.
Confirm the script loaded
Two quick checks:
- In the Network tab, filter for
optsensand reload the page. You should see the script request tocdn.optsens.comreturn200. - In the Console, check that the global object exists:
typeof window.OptSens; // "object" when loaded
OptSens.version; // script version string
If OptSens is undefined, the script did not load. See
banner not appearing.
Print debug info
OptSens.debug() prints a console group with the version, ready state,
banner configuration, current consent state and whether the banner is
visible:
OptSens.debug();
Wait for ready before reading state
The script resolves consent asynchronously. Read state inside the
ready event to avoid reading it too early:
OptSens.on('ready', function () {
console.log('Given:', OptSens.isConsentGiven());
console.log('Active:', OptSens.getActiveCategories());
console.log('Analytics:', OptSens.hasConsent('analytics'));
});
Common console checks
OptSens.hasConsent('analytics'); // true if analytics is consented
OptSens.isConsentGiven(); // true once the visitor chose
OptSens.getActiveCategories(); // ['necessary', 'analytics']
OptSens.consent; // full consent state object
OptSens.config; // banner configuration
See window.OptSens for the full method list.
Check that tags are blocked
A blocked inline script has its type set to text/plain until consent
is given. Inspect a tagged element in the Elements tab and confirm the
type attribute. Blocked iframes have their src removed and a
placeholder shown. For how this works, see
auto-blocking and
manual tagging.
The os_sid cookie
os_sid is a short-lived session cookie used for billing session counts.
It holds a random session ID and uses a 15 minute sliding window. The same visitor refreshing within 15 minutes counts as one session. It does
not store consent. Consent lives in os_consent. See the cookie list in
the developer overview.
Reset consent state for testing
To see the banner again as a first-time visitor would, clear the stored consent. There is no separate reset API. Use one of these:
| Method | What it does |
|---|---|
OptSens.withdrawConsent() | Clears consent, removes iframe placeholders, emits consent_update, shows the banner again |
OptSens.renew() | Clears consent and shows the banner again, without emitting consent_update |
| Clear site data | In dev tools, clear cookies (os_consent, os_sid) and the os_consent, os_visitor_id and os_banner_lang localStorage keys, then reload |
Clearing site data simulates a brand new visitor most closely.
SPA route changes
In a single-page app, listen for the route_change event to confirm the
script saw a navigation:
OptSens.on('route_change', function () {
console.log('OptSens saw a route change');
});
If the event never fires, your router is not notifying the script. See SPA support.