Nikita G
Nikita G

Reputation: 11

enable/disabling tracking consent with sitecore 10.1

Has anyone worked with enabling/disabling tracking consent with sitecore 10.1? I tried the below but it does not seem to work as consentChoice.IsGiven is always returned as true(even after the revoke code is executed): : https://doc.sitecore.com/xp/en/developers/101/sitecore-experience-platform/manage-a-contact-s-tracking-consent-choices.html Also, when I set explicitConsentForTrackingIsRequired to true for my site the tracking code starts giving an error.

Upvotes: 1

Views: 438

Answers (1)

Suneeth Sunkari
Suneeth Sunkari

Reputation: 1

Regarding

  1. consentChoice.IsGiven always returning true, my initial suspect is your browser cache, your previous site visit might have already captured or set SC_TRACKING_CONSENT (which is set on call to GiveConsent) , if this cookie exists consentChoice.IsGiven is always read from here.

You may need to test this better with either incognito(if using chrome also ensure no shared incognitos) or ensure to force hard refresh (clear cookies) before testing this.

  1. Tracking error code you are facing when explicitConsentForTrackingIsRequired is set to true, this could be due to multiple issues -> ensure xDB tracker is enabled before enabling the consent setting, or check if you have any code attempt to explicitly Start Tracking or access to Tracker.Current.Contact before User Consent has been given. This may throw random errors and error log would help pin point these if you have better example of errors facing.

In addition to these I had also faced errors using this in conjunction with sitecore forms: When using forms along with explicitConsentForTrackingIsRequired there is an issue where forms auto starts tracking on interaction with form elements , forms has a missing condition check for User Consent before starting tracking. Please check the answer here for workaround if it is the case.

Upvotes: 0

Related Questions