Skip to main content
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

ActionDescription
ConsentChangeSets 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
ParameterDescription
consentSets 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 codeDescription
invalidGroupThe specified group does not exist or is invalid.
invalidServiceThe specified service does not exist or is invalid.
Related modules, variables & methods Example showing how in a cookie banner consent per group and per service is controlled via checkboxes.
{{ 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>