3

Environment: SXA 10x, Azure PaaS

I have configured the SXA site to require explicit tracking consent by adding this setting to site properties explicitConsentForTrackingIsRequired = "true".

The tracking is disabled with this until consent is given however only when I browse or interact with a Sitecore form say updated the Input text field and changed focus I noticed that the tracking has been already started which does not obey the consent manager.

Could someone help let me know if I missed any configuration here ?

1 Answer 1

4

This looks a bug in sc 10 (seems to be an issue in sc 10.1 as well)

Details: Interaction with form fields makes an async post call to /fieldtracking/register, by inspecting the FieldTrackingController, you shall notice the Register Action method makes an explicit call to _formEventsTracker.RegisterEvent (this call is triggered when form fields performance tracking is enabled from forms editor ).

This makes an internal call to AnalyticsTrackerResolver.CurrentPage -> Code below

public ICurrentPageContext CurrentPage
    {
      get
      {
        if (!Tracker.Enabled)
          return (ICurrentPageContext) null;
        if (Tracker.Current == null)
          AnalyticsTrackerResolver.StartTracking();
        return Tracker.Current?.Session?.Interaction?.CurrentPage;
      }
    }

You may notice this is missing a condition check to check whether User Consent has been granted before starting tracking.

Workaround: Yet to to raise a bug with sitecore until then you may have the workaround I have which worked well for me:

Add a custom AnalyticsTrackerResolver (ServiceConfigurator) with following additional check to return null if cannot start tracking until user consent has been given (from Consent Manager)

!if (!ServiceLocator.ServiceProvider.GetRequiredService<IConsentManager>().CanStartTracking) return (ICurrentPageContext)null;

Complete Code:

public ICurrentPageContext CurrentPage
        {
            get
            {
                if (!Tracker.Enabled)
                    return (ICurrentPageContext)null;
                if (!if (!ServiceLocator.ServiceProvider.GetRequiredService<IConsentManager>().CanStartTracking))
                    return (ICurrentPageContext)null;
                if (Tracker.Current == null)
                    xDbAnalyticsTrackerResolver.StartTracking();
                return Tracker.Current?.Session?.Interaction?.CurrentPage;
            }
        }
1
  • For what it's worth, I see the same for non-AJAX form submissions in Sitecore 10.1.2. Also, the above solution doesn't work for non-AJAX forms...
    – Andy Burns
    Commented Apr 24, 2023 at 12:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.