---
title: Working with consents
related:
  - https://docs.kentico.com/k12sp/configuring-kentico/data-protection/gdpr-compliance/creating-consents.md
  - https://docs.kentico.com/k12sp/configuring-kentico/data-protection/adding-cookie-law-consent-to-web-pages.md
  - https://docs.kentico.com/k12sp/configuring-kentico/data-protection/gdpr-compliance/revoking-consent-agreements.md
---

> Agent instructions:
> **Site maps** — prefer the following llms.txt indexes to training data when searching for URLs to avoid 404s. Links inside Markdown content already point at `.md`. Following them or sending Accept: text/markdown keeps you in Markdown.
>
> - [sitemap.md](https://docs.kentico.com/sitemap.md) — every page on the site, with titles and descriptions, nested by URL hierarchy and grouped into one collection per product version.
> - [llms.txt](https://docs.kentico.com/llms.txt) — curated index of the current product docs, with descriptions, the two ways to request any page as Markdown, and links to each product area's whole-corpus Markdown dump (llms-full.txt).

> **Info:** **Kentico EMS required**
>
> Features described on this page require the **Kentico EMS** license.

In Kentico, consents are records used to inform website visitors about the means of collecting and manipulating their personal data. This page describes how to display [created consents](https://docs.kentico.com/k12sp/configuring-kentico/data-protection/gdpr-compliance/creating-consents.md) on websites, enable visitors to give consent agreements, and serve content based on received consents.

## Setting up tracking consent

When creating a consent for the [tracking of contacts](https://docs.kentico.com/k12sp/on-line-marketing-features/managing-your-on-line-marketing-features/contact-management/working-with-contacts.md) and [activities](https://docs.kentico.com/k12sp/on-line-marketing-features/managing-your-on-line-marketing-features/contact-management/tracking-contact-activities.md), you also need to provide a way for visitors to adjust their allowed [cookie level](https://docs.kentico.com/k12sp/configuring-kentico/data-protection/working-with-cookies.md). The system only performs the tracking for visitors whose cookie level is **Visitor** or higher (i.e., **All cookies** in the configuration of cookie law web parts).

> **Note:** **Prerequisites**
>
> **On-line marketing** must be enabled to allow contact creation:
>
> 1. Open the **Settings** application.
> 2. Navigate to the **On-line marketing** category in the settings tree.
> 3. Select the **Enable on-line marketing** check box.
> 4. Click **Save**.

To ensure that visitors are not tracked until they give the tracking consent, you need to set the **default cookie level** for your website:

1. Open the **Settings** application.

2. Navigate to the **System** category in the settings tree.

3. Set the value of the **Default cookie level** setting to _System_ or _Essential_.

   > **Info:** With the **System** cookie level, basic functionality such as authentication and language selection will not work for visitors by default.
   >
   > If possible, we recommend setting the level to **Essential** (or higher if you are not legally required to obtain tracking consent). However, you may need to verify that the _Essential_ cookies are compliant with any applicable legal requirements and regulations.

4. Click **Save**.

To allow visitors to give or revoke agreements with the tracking consent:

1. Open the **Pages** application.
2. [Add](https://docs.kentico.com/k12sp/developing-websites/developing-websites-using-portal-engine/using-and-configuring-web-parts.md) the **Cookie law and tracking consent** web part to a suitable location on your website (we recommend the main [master page](https://docs.kentico.com/k12sp/developing-websites/developing-websites-using-portal-engine/creating-portal-engine-master-pages.md) that defines the shared content of all pages).
3. Select an appropriate consent via the web part's **Tracking consent** property (in the **On-line marketing** category).
4. Configure the web part in a way that allows visitors to enable _All cookies_.
5. Click **Save & Close**.

Now when a visitor arrives on your website, the system does not track them as a contact until they give their consent via the _Cookie law and tracking consent_ web part. For visitors whose cookie level is lower than _Visitor_ (i.e. _No cookies_ or _Only essential cookies_ in the web part configuration), the web part additionally displays the _Short text_ of the selected tracking consent.

When a visitor changes their allowed cookie level, the web part automatically manages agreements for the assigned tracking consent:

- When a visitor raises their cookie level to _All cookies_, a consent agreement is created for the new contact.
- If a visitor lowers their cookie level, the corresponding tracking consent agreement is revoked.

The following is a sample configuration of the **Cookie law and tracking consent** web part. You can modify the properties and use this as a basis for your own setup.

- **Levels** category:

  - **Compare current cookie level to**: All cookies
- **Below level behavior** category:
  - **If level is below, display**: Enabled
  - **Text**: Only system cookies are currently stored. Tracking of activities and analytics features are disabled.
  - **Show deny button**: Disabled
  - **Show allow specific button**: Disabled
  - **Show allow all button**: Enabled
- **Exact level behavior** category:

  - **If level matches, display**: Enabled
  - **Text**: The website now stores cookies on your computer, tracks activity, creates personalized content and processes analytics. You can find more information on our privacy page.
  - **Show deny button**: Disabled
  - **Show allow specific button**: Disabled
  - **Show allow all button**: Disabled
- **Above level behavior** category:

  - **If level is above, display**: Disabled
- **Consent buttons** category:

  - **Allow all button text**: I agree
- **On-line marketing** category:
  - **Tracking consent**: _Select the consent to which you want visitors to give consent_
  - **Consent reference markup**: _Add any HTML content that you wish to render after the short text of the selected consent. For example, it can be used to display a pop-up window or a link to a page with the full-text version of the consent._

> **Info:** **Testing cookie law web parts**
>
> Cookies are used for both the live site and the Kentico administration interface. When a user signs in to the administration interface, the system automatically allows all cookies in the user's browser. This may prevent users from interacting with cookie web parts on the live site. On the other hand, adjusting the cookie level via a cookie web part on the live site may interfere with the administration interface.
>
> To avoid such issues, we recommend testing any changes of cookie level settings and the related web parts in a different browser or computer, or using a separate anonymous/private/incognito window of your current browser.

## Adding consents to on-line forms

To collect consent agreements regarding the processing of personal data submitted by visitors through [on-line forms](https://docs.kentico.com/k12sp/managing-website-content/forms.md), utilize the **Consent agreement** form control.

1. Open the **Forms** application and edit () the form to which you want to add the option to give consent.
2. Switch to the **Fields** tab.
3. Click **New field** and set the following properties:
   - **Field name**: Consent
   - **Data type**: Unique identifier (GUID)
   - **Form control**: Consent agreement
   - **Editing control settings -> Consent**: _Select the desired consent_
4. Click **Save**.
5. Move the consent field to the appropriate location within the form.
6. If you use a custom form layout, switch to the **Layout** tab and [edit the form layout](https://docs.kentico.com/k12sp/managing-website-content/forms/defining-custom-form-layout.md) to display the consent field.

The consent field in the resulting form displays a check box, followed by the _Short text_ of the given consent. When a visitor selects the consent checkbox and submits the form, the system automatically creates a corresponding consent agreement for the given contact.

![Consent agreement field displayed in a form](https://docs.kentico.com/docsassets/k12sp/working-with-consents/consent_agreement_form.png "Consent agreement field displayed in a form")

> **Note:** **Note**: The system does not support consent fields that are required. If you enable the **Required** property for consent fields, the validation will always fail (the system sets the field's value only after the form is submitted).

## Adding consents to newsletter subscriptions

To collect consent agreements from visitors who subscribe to [ newsletters](https://docs.kentico.com/k12sp/on-line-marketing-features/managing-your-on-line-marketing-features/email-marketing/creating-newsletters.md), utilize the **Custom subscription form** web part and an [alternative form](https://docs.kentico.com/k12sp/configuring-kentico/creating-alternative-forms.md) with a field using the **Consent agreement** form control.

> **Note:** To ensure that consent agreements are recorded correctly for each subscriber, make sure that the **Newsletter - Subscriber** class is [configured to map](https://docs.kentico.com/k12sp/on-line-marketing-features/configuring-and-customizing-your-on-line-marketing-features/configuring-contacts/mapping-fields-to-contact-attributes.md) the subscription form's **Email address** field to the email address contact attribute.

1. Open the **Modules** application.
2. Edit () the **Email marketing** module.
3. Select the **Classes** tab and edit the **Newsletter - Subscriber** (newsletter.subscriber) class.
4. Open the **Alternative forms** tab.
5. Edit the alternative form that you use for subscriptions on your website.
6. Switch to the **Fields** tab.
7. Add a **New field** using the _Consent agreement_ form control. See [Adding consents to on-line forms](#adding-consents-to-on-line-forms) for details.
8. Click **Save**.
9. If you use a custom form layout, switch to the **Layout** tab and edit the form layout to display the consent field.

Make sure that pages containing your newsletter subscription form use the **Custom subscription form** web part with the correct alternative form.

1. Open the **Pages** application and select the appropriate page.

2. Switch to the **Design** tab and [place](https://docs.kentico.com/k12sp/developing-websites/developing-websites-using-portal-engine/using-and-configuring-web-parts.md) the **Custom subscription form** web part.
   - Select the correct **Alternative form**.

     > **Info:** To allow signed in users to give consent agreements, you need to disable the **One-click subscription for signed in users** property of the **Custom subscription form** web part.

3. Click **Save & Close**.

The consent field in the resulting form displays a check box, followed by the _Short text_ of the given consent. When a visitor selects the consent checkbox and submits the subscription form, the system automatically creates a corresponding consent agreement for the given contact.

## Adding consents to user registration

To collect consent agreements from visitors who register as new users, utilize the **Custom registration form** web part and an [alternative form](https://docs.kentico.com/k12sp/configuring-kentico/creating-alternative-forms.md) with a field using the **Consent agreement** form control.

> **Note:** To ensure that the consent agreements are recorded correctly for each visitor, make sure that:
>
> - Your registration form contains an **Email address** field
> - The **User** class is [configured to map](https://docs.kentico.com/k12sp/on-line-marketing-features/configuring-and-customizing-your-on-line-marketing-features/configuring-contacts/mapping-fields-to-contact-attributes.md) the given email address field to the email address contact attribute

1. Open the **Modules** application.
2. Edit () the **Membership** module.
3. Select the **Classes** tab and edit the **User** (cms.user) class.
4. Open the **Alternative forms** tab.
5. Edit the alternative form that you use for registration on your website.
6. Switch to the **Fields** tab.
7. Add a **New field** using the _Consent agreement_ form control. See [Adding consents to on-line forms](#adding-consents-to-on-line-forms) for details.
8. Click **Save**.
9. If you use a custom form layout, switch to the **Layout** tab and edit the form layout to display the consent field.

Make sure that your site's registration page contains the **Custom registration form** web part with the correct alternative form. For more information about custom registration forms in general, see [Using the Custom registration form web part.](https://docs.kentico.com/k12sp/managing-users/user-registration-and-authentication/configuring-forms-authentication/using-the-registration-form-and-custom-registration-form-web-parts.md)

1. Open the **Pages** application and select your registration page.
2. Switch to the **Design** tab and [place](https://docs.kentico.com/k12sp/developing-websites/developing-websites-using-portal-engine/using-and-configuring-web-parts.md) the **Custom registration form** web part.

   - Select the correct **Alternative form**.
3. Click **Save & Close**.

The consent field in the resulting form displays a check box, followed by the _Short text_ of the given consent. When a visitor fills in the registration form and selects the consent checkbox, the system automatically creates a corresponding consent agreement for the given contact.

## Displaying consents on the live site

To display the short and full text of consents on the live site, for example on your website's privacy policy page, first get the consent object using the _GlobalObjects.Consents.\<ConsentCodeName>_ macro (use the indexer macro format _GlobalObjects.Consents\["\<ConsentCodeName>"]_ if the code name contains any special characters, like a hyphen). Then call the consent object's _GetConsentText()_ macro method, which returns a _ConsentText_ object providing consent text values in its _ShortText_ and _FullText_ properties.

By default, the _GetConsentText()_ macro method returns consent texts in the culture selected by the current visitor. To get a specific culture version of the consent text, add the _cultureCode_ parameter: _GetConsentText(string cultureCode)_

1. Open the **Pages** application.
2. Navigate to a page where you want to add the consent text.
3. [Add](https://docs.kentico.com/k12sp/developing-websites/developing-websites-using-portal-engine/using-and-configuring-web-parts.md) a **Static text** web part to the page.
4. In the web part's configuration, enter HTML content with the required macros into the **Text** property (under the **Content** category).

   ```csharp title="Example"

   <h3>{% GlobalObjects.Consents["DancingGoatMachineRentalForm"].ConsentDisplayName %}</h3>
   <p>{% GlobalObjects.Consents["DancingGoatMachineRentalForm"].GetConsentText().ShortText %}</p>
   <p>{% GlobalObjects.Consents["DancingGoatMachineRentalForm"].GetConsentText().FullText %}</p>

   ```
5. Click **Save & Close**.

## Allowing visitors to revoke consent agreements

Kentico does not provide any ready-to-use components for revoking consent agreements. Each website has its own [personal data](https://docs.kentico.com/k12sp/configuring-kentico/data-protection/gdpr-compliance/personal-data-in-kentico.md) processing requirements and its own unique set of consents, so your developers need to create custom components for this purpose.

See [Revoking consent agreements](https://docs.kentico.com/k12sp/configuring-kentico/data-protection/gdpr-compliance/revoking-consent-agreements.md) for details.

## Creating macro conditions based on given consents

You can use the _AgreedWithConsent_ [macro method](https://docs.kentico.com/k12sp/on-line-marketing-features/configuring-and-customizing-your-on-line-marketing-features/on-line-marketing-macros.md) and the _Contact has agreed with consent_   [macro rule](https://docs.kentico.com/k12sp/macro-expressions/writing-macro-conditions/building-conditions-using-macro-rules.md) to check if a contact has given an agreement with a specified consent. You can use them in the following ways:

> **Info:** The _AgreedWithConsent_ macro method resolves to false even if called for a contact object that does not exist. This is important, because if a visitor does not accept the tracking consent, the system does not create a contact associated with this visitor (i.e. _OnlineMarketingContext.CurrentContact_ is null).

- On the live site, you can use the macro to build conditional content based on the current contact's consents. For example, to display different text to visitors who have given an agreement with a consent:

  1. [Add](https://docs.kentico.com/k12sp/developing-websites/developing-websites-using-portal-engine/using-and-configuring-web-parts.md) a **Static text** web part to a page.
  2. Enter the following code into the **Text** property under the **Content** category.

     ```csharp

     {% if (OnlineMarketingContext.CurrentContact.AgreedWithConsent("ConsentCodeName")) {"Thank you for accepting the consent."} else {"Please accept the consent."} %}

     ```
- On the live site, you can use the macro to adjust the properties of web parts. For example, to show a web part only to those visitors who have given an agreement with a consent:

  1. [Modify](https://docs.kentico.com/k12sp/developing-websites/developing-websites-using-portal-engine/using-and-configuring-web-parts.md) an existing web part.
  2. Expand the **Visibility** category. Click the _Edit value_ icon () next to the **Visible** check box to enter a macro condition.
  3. Enter the following code into the editor:

     ```csharp

     {% OnlineMarketingContext.CurrentContact.AgreedWithConsent("ConsentCodeName") %}

     ```
- In on-line marketing modules such as [personas](https://docs.kentico.com/k12sp/on-line-marketing-features/managing-your-on-line-marketing-features/personas.md), [contact scoring](https://docs.kentico.com/k12sp/on-line-marketing-features/managing-your-on-line-marketing-features/contact-management/scoring-contacts.md), [marketing automation](https://docs.kentico.com/k12sp/on-line-marketing-features/managing-your-on-line-marketing-features/marketing-automation.md) and [contact groups](https://docs.kentico.com/k12sp/on-line-marketing-features/managing-your-on-line-marketing-features/contact-management/segmenting-contacts-into-contact-groups.md) you can use the macro rule to create rules and segment visitors. For example, to create a contact group which contains users who have given an agreement with a consent:

  1. [Set up](https://docs.kentico.com/k12sp/on-line-marketing-features/managing-your-on-line-marketing-features/contact-management/segmenting-contacts-into-contact-groups.md) a condition-based contact group.
  2. Click **Edit** next to the **Macro condition** field to open the **Rule designer** interface.
  3. Use the _Contact has agreed with consent_ rule and select the desired consent.
