Manually delete tracking cookies

Overview

Sitefinity CMS does not automatically delete the tracking cookies in the visitor’s browser. These cookies may come from Google Tag Manger (GTM) or any other third-party JavaScript code, which is inserted on the page. If the visitor does not consent to tracking, you must delete these cookies manually – by using the features of the tag manager, or with code using Sitefinity CMS API.

In this article, you learn how to manually delete the tracking cookies.

Sample

To delete a cookie, you need to know its name and its domain.

If you are using Google Analytics, its cookie names look like _ga_[MEASURMENT_ID]. The MEASURMENT_ID is a value unique for your Google Analytics account and site.

Following is an example code on how to delete cookies on declined consent. This code sample works with the Sitefinity CMS built-in consent tracking feature:

The deleteCookie method accepts a cookie name, and you must call it using the exact name of the cookie that you want to delete.

If you want to use external consent manager, you need write a JavaScript logic, similar to the sample above, but using the external provider’s API.
For example, window.TrackingConsentManager in the code above is an object available, only if the Sitefinity CMS build-in consent is configured. To detect the ConsentChanged event, you must change it to your tag manager’s API.

Delete tracking cookie using GTM

You can use the previous sample directly in Sitefinity CMS or in GTM.
To do the latter, perform the following:

  1. Go to Google Tag Manager.
  2. Click the account holding the tag you want to hold your new tag
  3. Click New Tag.
  4. Name the tag.
  5. Click Tag Configuration and under Choose tag type select Custom Html.
  6. In the HTML field, add your code
  7. Click Triggering and select All Pages.
  8. Save and submit your tag.

Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Get started with Integration Hub | Sitefinity Cloud | Sitefinity SaaS

This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.

Web Security for Sitefinity Administrators

This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.

Foundations of Sitefinity ASP.NET Core Development

The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.

Was this article helpful?