> ## Documentation Index
> Fetch the complete documentation index at: https://dokumentation.websale.de/llms.txt
> Use this file to discover all available pages before exploring further.

# Consent

> Reference for WEBSALE consent actions used to set or change the visitor's consent for non-essential cookies and external services in the frontend.

This section describes the available actions in the Consent area. With these actions, the user's consent to non-essential cookies and services can be set or changed.

***

## Actions overview

| **Action**      | **Description**                                                |
| --------------- | -------------------------------------------------------------- |
| `ConsentChange` | Sets or changes consent to non-essential cookies and services. |

***

## Actions

### ConsentChange

This action sets or changes the user's consent to non-essential cookies. Consent can be controlled at the top level (entire consent object), at the group level, or at the level of individual services within a group.

**Usage example**\
Useful in a cookie banner, for example, to give the user the option of granting or revoking consent for all cookies at once, for specific groups (e.g., "Marketing", "Statistics"), or for individual services (e.g., "Google Analytics") in a targeted manner.

**Parameters**

| **Parameter**                               | **Description**                                                                                                       |
| ------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
| `consent`                                   | Sets consent at the top level for all non-essential cookies.                                                          |
| `groups.<groupName>`                        | Sets consent for a specific consent group. `<groupName>` stands for the name of the respective group.                 |
| `groups.<groupName>.services.<serviceName>` | Sets consent for an individual service within a group. `<serviceName>` stands for the name of the respective service. |

**Error codes**

| **Error code**   | **Description**                                     |
| ---------------- | --------------------------------------------------- |
| `invalidGroup`   | The specified group does not exist or is invalid.   |
| `invalidService` | The specified service does not exist or is invalid. |

**Related modules, variables & methods**

* [\$wsConsent](/en/frontend/referenz/module/wsconsent)
* [\$wsConsent.groups](/en/frontend/referenz/module/wsconsent#\$wsconsent-groups)
* [\$wsConsent.services](/en/frontend/referenz/module/wsconsent#\$wsconsent-services)

**Example** showing how in a cookie banner consent per group and per service is controlled via checkboxes.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
{{ var $myActionConsentChange = $wsActions.create("ConsentChange") }}
<form method="post" action="{{= $wsViews.current.url() }}">
    <input type="hidden" name="wscsrf" value="{{= $myActionConsentChange.csrf }}">
    <input type="hidden" name="wsact" value="{{= $myActionConsentChange.id }}">
    {{ foreach $myConsentGroup in $wsConsent.groups }}
        <input type="checkbox" name="groups.{{= $myConsentGroup.name }}.consent"{{ if $myConsentGroup.allowed }} checked{{ /if }}>
        {{ foreach $myConsentService in $myConsentGroup.services }}
            <input type="checkbox" name="groups.{{= $myConsentGroup.name }}.services.{{= $myConsentService.name }}"{{ if $myConsentService.allowed }} checked{{ /if }}>
        {{ /foreach }}
    {{ /foreach }}
    <button type="submit">Save changes.</button>
</form>
```
