Reminder: As of August 9th, the demo API key will only be allowed to make GET requests. Please see the announcement for more details.

Get privacy consent status

Last updated October 24, 2018

_hsq.push(['addPrivacyConsentListener', callbackFunction]);

Allows you to get the privacy consent status of the current visitor.

If the privacy policy consent banner is not enabled, or if the visitor has previously seen the banner and clicked accept or decline, the callbackFunction will be called as soon as the function is processed (immediately if the tracking code is already loaded, or after the tracking code finishes loading if the function is pushed to _hsq before the tracking code is loaded).

If the consent banner is enabled, the callbackFunction will be called when the visitor clicks on the accept or decline button. 

The callbackFunction accepts a consent object as its only argument.

The consent object has a single allowed property that will be true if:

  • The privacy policy consent banner is not enabled, or is enabled in notify-only mode.
  • The visitor clicks accept on the banner when opt-in mode is enabled.
  • The visitor has previously clicked accept on the banner when opt-in mode is enabled.

The property will be false if the consent banner is enabled in opt-in mode and the visitor clicks or has previously clicked the decline button.