Manually delete tracking cookies


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.


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.

Web Security for Sitefinity Administrators

The free standalone Web Security lesson teaches administrators how to protect your websites and Sitefinity instance from external threats. Learn to 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?