> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

## Resource: About Consent Apps

## Article: About Consent Apps

## Article Link: https://dev.wix.com/docs/build-apps/launch-your-app/legal-and-security/about-consent-apps.md

## Article Content:

# About Consent Apps

This article is a comprehensive guide for consent app creators that explains everything you need to know about managing consent policies on Wix sites.

Only 1 consent app should be installed on a site at a time to avoid conflicting changes to consent settings. Make sure you convey this to your users.

Before you read this article, make sure you're familiar with the GDPR and the cookie consent requirements that Wix apps must implement. For information on these topics, see [About GDPR and Data Protection Compliance](https://dev.wix.com/docs/build-apps/launch-your-app/legal-and-security/gdpr-compliance/about-gdpr-and-data-protection.md).

## Managing consent policies

There are 2 types of consent policies to be aware of when developing a consent app:

- Visitor consent policies
- Default consent policies

### Visitor consent policies

Every visitor to a Wix site has their own visitor consent policy that defines what types of cookies and related technologies they allow.

Visitor consent policies can be managed using the [Consent Policy API](https://dev.wix.com/docs/sdk/host-modules/site/consent-policy-manager/introduction.md).

### Default consent policies

When a visitor first arrives on the site, their visitor consent policy is configured to match the site's default consent policy.

Every site's default consent policy initially allows all types of cookies and related technologies. You can manage a site's default consent policy using the [Site Properties API](https://dev.wix.com/docs/rest/business-management/site-properties/properties/introduction.md).

### Example use cases

#### Managing visitor consent in a cookie consent banner

You're developing an app that adds a cookie consent banner to a site. When the visitor chooses their consent settings in the banner, you call [`setConsentPolicy()`](https://dev.wix.com/docs/sdk/frontend-modules/window/consent-policy/set-consent-policy.md) to update their policy with their chosen settings.

##### Implementation examples

<details>
  <summary>Basic consent banner HTML fragment for an embedded script using the Consent Policy Manager API</summary>
  
```html
<div id="consent-banner" style="position: fixed; bottom: 0; width: 100%; background: #333; color: white; padding: 20px; z-index: 1000;">
  <p>We use cookies to improve your experience. Please choose your preferences:</p>
  <button onclick="acceptAll()">Accept All</button>
  <button onclick="applyMinimalConsent()">Reject All</button>
</div>

<script>

import { consentPolicy } from "@wix/site-window";

async function acceptAll() {
  await consentPolicy.setConsentPolicy({
    essential: true,
    functional: true,
    analytics: true,
    advertising: true,
    dataToThirdParty: true
  });
  hideBanner();
}

async function applyMinimalConsent() {
  await consentPolicy.setConsentPolicy({
    essential: true,
    functional: false,
    analytics: false,
    advertising: false,
    dataToThirdParty: false
  });
  hideBanner();
}

function hideBanner() {
  document.getElementById('consent-banner').style.display = 'none';
}

// Check if consent has already been provided
consentPolicy.getCurrentConsentPolicy().then(policy => {
  if (!policy.defaultPolicy) {
    hideBanner();
  }
});
</script>
```

</details>

<details>
  <summary>Basic consent banner React component using the Consent Policy Manager API</summary>

```jsx
import React, { useState, useEffect } from 'react';
import { consentPolicy } from "@wix/site-window";

const ConsentBanner = () => {
  const [showBanner, setShowBanner] = useState(false);
  const [currentPolicy, setCurrentPolicy] = useState(null);

  useEffect(() => {
    checkConsentStatus();
  }, []);

  const checkConsentStatus = async () => {
    try {
      const policy = await consentPolicy.getCurrentConsentPolicy();
      setCurrentPolicy(policy);
      setShowBanner(policy.defaultPolicy);
    } catch (error) {
      console.error('Error checking consent status:', error);
    }
  };

  const handleAcceptAll = async () => {
    try {
      await consentPolicy.setConsentPolicy({
        essential: true,
        functional: true,
        analytics: true,
        advertising: true,
        dataToThirdParty: true
      });
      setShowBanner(false);
    } catch (error) {
      console.error('Error accepting all:', error);
    }
  };

  const handleMinimalConsent = async () => {
    try {
      await consentPolicy.setConsentPolicy({
        essential: true,
        functional: false,
        analytics: false,
        advertising: false,
        dataToThirdParty: false
      });
      setShowBanner(false);
    } catch (error) {
      console.error('Error applying minimal consent:', error);
    }
  };

  if (!showBanner) return null;

  return (
    <div className="consent-banner">
      <div className="consent-content">
        <h3>Cookie preferences</h3>
        <p>We use cookies to enhance your experience. Please choose your preferences:</p>
        <div className="consent-buttons">
          <button onClick={handleAcceptAll} className="btn-accept">
            Accept All
          </button>
          <button onClick={handleMinimalConsent} className="btn-reject">
            Reject All
          </button>
        </div>
      </div>
    </div>
  );
};

export default ConsentBanner;
```

</details>


#### Managing the default site consent policy in a cookie consent banner

You're developing an app with a cookie consent banner. When a user installs and activates your app, you want to block all types of cookies and related technologies until the visitor specifically consents to them via your banner. To do this, you configure a dashboard page where the user can activate your banner. When they activate it, you call [`updateConsentPolicy()`](https://dev.wix.com/docs/api-reference/business-management/site-properties/properties/update-consent-policy.md) with all `consentPolicy` types except `essential` set to `false`. If they deactivate your banner, you call `updateConsentPolicy()` again to reset the default site consent policy to allow all types.

##### Implementation examples

The following are examples of functions you could implement to enable or disable a consent banner, such as in a dashboard page in your app.

<details>
  <summary>Javascript SDK backend implementation example</summary>

```javascript
import { siteProperties } from '@wix/business-tools';

// When enabling the consent banner, reject optional cookies by default
async function enableConsentBanner() {
  await siteProperties.updateConsentPolicy({
    essential: true, 
    functional: false, 
    analytics: false, 
    advertising: false, 
    dataToThirdParty: false 
  });
  
  console.log('Default policy set to require explicit consent');
}

// When disabling the consent banner allow cookies by default
// Used when the user disables the banner in app settings
async function disableConsentBanner() {
  await siteProperties.updateConsentPolicy({
    essential: true,
    functional: true,
    analytics: true,
    advertising: true,
    dataToThirdParty: true
  });
  
  console.log('Default policy set to allow cookies');
}
```

</details>

<details>
  <summary>REST API implementation example</summary>

```javascript
// When enabling the consent banner, reject optional cookies by default
async function enableConsentBannerREST() {
  const response = await fetch('https://www.wixapis.com/site-properties/v4/properties/policy', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${accessToken}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      consentPolicy: {
        essential: true,
        functional: false,
        analytics: false,
        advertising: false,
        dataToThirdParty: false
      }
    })
  });
  
  if (response.ok) {
    console.log('Default policy updated successfully');
  }
}

// When disabling the consent banner allow cookies by default
// Used when the user disables the banner in app settings
async function disableConsentBannerREST() {
  const response = await fetch('https://www.wixapis.com/site-properties/v4/properties/policy', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${accessToken}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      consentPolicy: {
        essential: true,
        functional: true,
        analytics: true,
        advertising: true,
        dataToThirdParty: true
      }
    })
  });
  
  if (response.ok) {
    console.log('Default policy updated successfully');
  }
}
```

</details>

## App removal

When a Wix user removes your app from a site, Wix resets the site's default consent policy to allow all types of cookies and related technologies.

Wix applies this reset to apps it recognizes as consent apps. An app qualifies by having the [Manage Consent Policy permission](https://dev.wix.com/docs/build-apps/develop-your-app/auth/permissions/configure-permissions-for-your-app.md), the same permission your app needs to call the [Update Consent Policy](https://dev.wix.com/docs/api-reference/business-management/site-properties/properties/update-consent-policy.md) method.

Wix doesn't reset the policy if another consent app is still enabled on the site, including the Wix cookie banner app. That app may still rely on the current policy.

## Required extensions

When creating a consent app, you'll need at least the following extensions:

- **[Embedded script extension](https://dev.wix.com/docs/build-apps/develop-your-app/extensions/site-extensions/embedded-scripts/about-embedded-scripts.md):** You'll need an embedded script to load interactive functionality that allows site visitors to specify their consent settings, such as a cookie consent banner. Embedded scripts run on every page of a site, so regardless of the visitor's entry point, they will be given the option to configure their consent settings.
- **[Dashboard page extension](https://dev.wix.com/docs/build-apps/develop-your-app/extensions/dashboard-extensions/dashboard-pages/about-dashboard-page-extensions.md):** You'll need a dashboard page extension to allow users to activate or deactivate your app, customize your app's settings, and complete the setup of embedded scripts.

## Overriding consent categories of app embeds

Your app can optionally manage the consent categorization of scripts in other Wix apps.

Every embedded script in a Wix app must have a category, also referred to as a type. These categories are used to classify scripts for consent purposes according to GDPR and other data protection guidelines. Read more about [embedded script categories](https://dev.wix.com/docs/build-apps/develop-your-app/extensions/site-extensions/embedded-scripts/about-embedded-scripts.md#embedded-script-types). 

You can override the consent categories for installed apps' embedded script extensions using the [Consent Configs API](https://dev.wix.com/docs/api-reference/business-management/cookie-consent-policy/consent-configs/introduction.md). For example, you could create a dashboard page that allows the site owner to manage the consent categories of other apps they have installed.

## Testing your app

It's important to test your app's consent functionality to ensure it functions correctly. We recommend the following flow to test your app:

1. Install your app on a new site and check that no scripts are blocked.
2. Enable your app in your dashboard page.
3. Visit your site and check that your app's interface, such as a banner, appears.
4. Check that all non-essential scripts are now blocked by the sites default consent policy.
5. Check that making and accepting changes in your app's interface triggers a call to update the visitor's consent policy, and that when this happens, any unblocked scripts start running.
6. Check that turning off the banner in your dashboard page changes the site's default policy back to allowing all categories.

## See also

+ [Consent Policy API - SDK](https://dev.wix.com/docs/sdk/host-modules/site/consent-policy-manager/introduction.md)
+ [Site Properties API - SDK](https://dev.wix.com/docs/api-reference/business-management/site-properties/properties/update-consent-policy.md)
+ [Site Properties API - REST](https://dev.wix.com/docs/rest/business-management/site-properties/properties/update-consent-policy.md)
+ [GDPR Compliance Guidelines](https://gdpr.eu/)
+ [CCPA Information](https://oag.ca.gov/privacy/ccpa)