Note: The APIs in @wix/site-window.ConsentPolicy
can only be used in frontend code.
The consent policy helps you comply with GDPR and CCPA regulations, and allows site visitors to control their information.
Set up the site consent policy and cookie consent banners in a site's Privacy Center.
To use the Consent Policy API, install the @wix/site-window
package.
Follow the installation instructions for your development environment.
Development environment | Installation method |
---|---|
Wix sites (editor or IDE) | Use the package manager. |
Wix sites (local IDE) | Run wix install @wix/site-window using the Wix CLI. |
Blocks apps | Use the same installation method as Wix sites. |
CLI and self-hosted apps | Run npm install @wix/site-window or yarn add @wix/site-window . |
To import the package in your code:
Gets the site visitor's consent policy regarding allowed cookies and 3rd-party data transfers for GDPR or CCPA compliance.
Retrieves the site visitor's consent policy details, including which cookies are allowed and whether data transfer to 3rd parties is permitted.
function getCurrentConsentPolicy(): Promise<PolicyDetails>;
import { consentPolicy } from "@wix/site-window";
// ...
const policyDetails = await consentPolicy.getCurrentConsentPolicy();
const policy = policyDetails.policy;
/* policyDetails value:
*
* {
* "defaultPolicy" : true,
* "policy" : {
* "essential" : true,
* "functional" : true,
* "analytics" : true,
* "advertising" : true,
* "dataToThirdParty" : true
* },
* "createdDate" : 2020-07-20T12:33:09.775Z
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.