getCurrentConsentPolicy( )
Gets the user's consent policy regarding allowed cookies and 3rd-party data transfer, such as for GDPR or CCPA purposes.
Description
The getCurrentConsentPolicy()
function returns the
consent policy details of the user, meaning, which cookies the user allows and whether data transfer
to 3rd parties is allowed.
The consent policy helps you comply with GDPR and CCPA regulations and lets your users control their information. The site owner sets up the site consent policy and cookie consent banners in the site's Privacy Center.
Notes:
The APIs in
wix-users
are only partially functional when previewing your site. View a published version of your site to see their complete functionality.The APIs in
wix-users
can only be used once the page has loaded. Therefore, you must use them in code that is contained in or is called from the onReady() event handler or any element event handler.Cookie consent banners are only available on the published version of your site.
Syntax
function getCurrentConsentPolicy(): PolicyDetails
getCurrentConsentPolicy Parameters
This function does not take any parameters.
Returns
Return Type:
NAME
TYPE
DESCRIPTION
boolean
Whether the policy is the default consent policy set by the site owner. If true
, either the user has not set a policy or the site owner has reset the policy.
Policy
An object representing the user's current consent policy.
Date
If a cookie exists in the browser defining the current consent policy, the date the policy was set. Otherwise, undefined.
Was this helpful?
Get a user's consent policy
Code Example
1import { getCurrentConsentPolicy } from 'wix-users';23// ...45const policyDetails = getCurrentConsentPolicy();67/* policyDetails:8 *9 * {10 * "defaultPolicy" : true,11 * "policy" : {12 * "essential" : true,13 * "functional" : true,14 * "analytics" : true,15 * "advertising" : true,16 * "dataToThirdParty" : true17 * },18 * "createdDate" : 2020-07-20T12:33:09.775Z19 * }20 */