Walkthrough: Configuring a website to require explicit consent for tracking

Current version: 10.3

In Sitecore 10 and later, you can configure a website to require explicit consent from contacts before web tracking is started. Contacts that do not provide explicit consent are not tracked. Use Sitecore's API calls for reading, giving, and revoking consent to manage a contact's consent choices - for example, in the context of a cookie consent banner.

This walkthrough describes how to:

  • Configure a site to require explicit consent

  • Configure service page tracking

Note

Sitecore does not provide a default cookie consent banner rendering.

You can require explicit consent for tracking on a per-site basis.

To require explicit consent:

  • Set the explicitConsentForTrackingIsRequired attribute on the <site> element to true as shown:

    RequestResponse
    <configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" 
    xmlns:set="http://www.sitecore.net/xmlconfig/set/">
        <sitecore>
             <sites>    
                <site name="mywebsite" set:enableTracking="true" set:explicitConsentForTrackingIsRequired="true" />
            </sites>
        </sitecore>
    </configuration>

Configure service page tracking

By default, service pages belong to the service site, which means that they are not tracked as pages of the current site. Therefore, the tracking of service pages is not aligned with contact’s consent for the current site.

To track service pages as pages belonging to the current site, and thereby prevent the tracking of visitors that have opted out of tracking, choose one of the following:

  • Move all service pages out of the /sitecore/service folder and update global settings.

  • Create site-specific service pages and update site-specific settings.

Option 1: Move global service pages

To track service pages as pages visited under the current site, move all pages out of the <wwwroot>/sitecore/services folder. To do this:

  • Move each of the following files to the root folder or a new subfolder and update the corresponding global setting:

    Original file location

    New location

    Global setting (<wwwroot>/App_Config/Sitecore.config)

    Notes

    /sitecore/service/error.aspx

    /error.aspx

    ErrorPage

    /sitecore/service/noaccess.aspx

    /noaccess.aspx

    NoAccessUrl

    /sitecore/service/nolicense.aspx

    /nolicense.aspx

    NoLicenseUrl

    /sitecore/service/nolayout.aspx

    /nolayout.aspx

    LayoutNotFoundUrl

    /sitecore/service/notfound.aspx

    /notfound.aspx

    ItemNotFoundUrl

    -

    /nopublishable.aspx

    NoPublishableUrl

    This page does not exist in default. Create a copy of any other services page (such as error.aspx) and edit the content.

    /sitecore/service/notfound.aspx

    /notfound.aspx

    LinkItemNotFoundUrl

    By default, this setting has the same value as the ItemNotFoundUrl setting.

Option 2: Create site-specific service pages

Alternatively, you can create site-specific service pages. To do this:

  1. Create copies of the following files and move them to the web root or a new subfolder. See the following table for examples:

    Original file

    Copied file

    Notes

    /sitecore/service/error.aspx

    /error-docsitecorecom.aspx

    /sitecore/service/noaccess.aspx

    /noaccess-dotsitecorecom.aspx

    /sitecore/service/nolicense.aspx

    /nolicense-docsitecorecom.aspx

    /sitecore/service/nolayout.aspx

    /nolayout-docsitecorecom.aspx

    /sitecore/service/notfound.aspx

    /notfound-docsitecorecom.aspx

    -

    /nopublishable-docsitecorecom.aspx

    This page does not exist in default. Create a copy of any other services page (such as error.aspx) and edit the content.

    /sitecore/service/notfound.aspx

    /notfound-docsitecorecom.aspx

    By default, this setting has the same value as the ItemNotFoundUrl setting.

  2. Add the following attributes to the site node of the site (or sites) that require explicit consent for tracking and set the values to the custom pages you created:

    • errorPage

    • noAccessUrl

    • noLicenseUrl

    • layoutNotFoundUrl

    • itemNotFoundUrl

    • linkItemNotFoundUrl

    • noPublishableUrl

    For example:

    RequestResponse
    <site name="website" enableTracking="true" explicitConsentForTrackingIsRequired="true" itemNotFoundUrl="/notfound-docsitecorecom.aspx" ... />

Be aware that:

  • If you do not specify site-specific service pages, Sitecore directs visitors to the global service pages.

  • It does not matter what name you give the service page, but remember that the URL is visible to visitors.

Do you have some feedback for us?

If you have suggestions for improving this article,