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
- Navigate to the Google Tag Manager console and click your account.
- Click Variables.
- Under User-defined Variables, click New.
- Click the Variable Configuration card.
- In Choose variable type, choose 1st Party Cookie.
- In Cookie Name, enter sf-tracking-consent.
- In Format Value select Convert null to… and enter false.
- In Format Value select Convert undefined to… and enter false.
- Click Save and name the variable.
For example,enter Sitefinity Consent tracking cookie.
Create a trigger
- In the menu on the left, click Triggers » New.
- Click the Trigger Configuration card.
- In Choose trigger type, select Page View.» Some Page Views
- In the input boxes under Fire this trigger when an Event occurs and all of these conditions are true, enter the following:
- The name of the variable from Step 9 of the previous procedure.
For example, enter Sitefinity Consent tracking cookie
- In the next two input boxes, enter equals and false
- Click Save and name the trigger.
Create a tag
- Click Tags » New.
- Click the Tag Configuration card.
- In Choose tag type, select Google Analytics: GA4 Configuration.
- In Measurement ID, add your GA4 measurement ID.
- Click the Triggering card.
- Select All Pages.
- Click Add Exception.
- Select your blocking trigger that you created in Step 14.
- 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
.