Search.../

getCurrentConsentPolicy( )

Gets the user's consent policy regarding allowed cookies and third-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 third 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:

PolicyDetails

Was this helpful?

Get a user's consent policy

Code Example

Copy Code
1import { getCurrentConsentPolicy } from 'wix-users';
2
3// ...
4
5const policyDetails = getCurrentConsentPolicy();
6
7/* policyDetails:
8 *
9 * {
10 * "defaultPolicy" : true,
11 * "policy" : {
12 * "essential" : true,
13 * "functional" : true,
14 * "analytics" : true,
15 * "advertising" : true,
16 * "dataToThirdParty" : true
17 * },
18 * "createdDate" : 2020-07-20T12:33:09.775Z
19 * }
20 */