Configure Google Tag Manager to work with the Sitefinity tracking cookie

Overview

Tracking consent user choice is saved in a cookie named sf-tracking-consent on the client’s browser. The cookie is set to true when the user consents to tracking their behavior, and to false when the user declines. This cookie is used by both Sitefinity CMS and Sitefinity Insight.

When integrating Google Tag Manager (GTM), you must ensure that GTM handles this cookie and sets it to reflect the user consent correctly. That is, your third-party solution must turn off itself when the cookie is set to false.

In this article, you learn how to configure Google Tag Mager to be in sync with the state of the sf-tracking-consent cookie.

You must perform the following procedures in the GTM console:

Create a variable

  1. Navigate to the Google Tag Manager console and click your account.
  2. Click Variables.
  3. Under User-defined Variables, click New.
  4. Click the Variable Configuration card.
  5. In Choose variable type, choose 1st Party Cookie.
  6. In Cookie Name, enter sf-tracking-consent.
  7. In Format Value select Convert null to… and enter false.
  8. In Format Value select Convert undefined to… and enter false.
  9. Click Save and name the variable.
    For example,enter  Sitefinity Consent tracking cookie.

Create a trigger

  1. In the menu on the left, click Triggers » New.
  2. Click the Trigger Configuration card.
  3. In Choose trigger type, select Page ViewSome Page Views
  4. In the input boxes under Fire this trigger when an Event occurs and all of these conditions are true, enter the following:
    1. The name of the variable from Step 9 of the previous procedure.
      For example, enter Sitefinity Consent tracking cookie
    2. In the next two input boxes, enter equals and false
  5. Click Save and name the trigger.

Create a tag

  1. Click Tags » New.
  2. Click the Tag Configuration card.
  3. In Choose tag type, select Google Analytics: GA4 Configuration.
  4. In Measurement ID, add your GA4 measurement ID.
  5. Click the Triggering card.
  6. Select All Pages.
  7. Click Add Exception.
  8. Select your blocking trigger that you created in Step 14.
  9. Click Save and name the tag.

RESULT: You have created a GTM tag that works for all page views expect when the Exception condition is met, which is when the Sitefinity tracking cookie is set to false.

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?