Search.../

getCurrentConsentPolicy( )

Gets the visitor'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 visitor, meaning, which cookies the visitor allows and whether data transfer to 3rd parties is allowed.

Syntax

function getCurrentConsentPolicy(): PolicyDetails

getCurrentConsentPolicy Parameters

This function does not take any parameters.

Returns

Return Type:

PolicyDetails
NAME
TYPE
DESCRIPTION
defaultPolicy
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
Policy

An object representing the user's current consent policy.

createdDate
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 members's consent policy

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