Module Permissions
It is possible to disable the individual modules of Umbraco Engage (Analytics, A/B testing, Personalization) through code based on any criteria you want.
You could choose to give visitors control over these settings through a cookie bar on your site.
To do this you have to create an implementation of the Umbraco.Engage.Infrastructure.Permissions.ModulePermissions.IModulePermissions interface and override our default implementation.
This interface defines 3 methods that you will have to implement:
/// <summary>
/// Indicates if A/B testing is allowed for the given request context.
/// If false, the visitor will not be assigned to any A/B tests and will not
/// see any active A/B test content.
/// </summary>
/// <param name="context">Context of the request</param>
/// <returns>True if A/B testing is allowed, otherwise false.</returns>
bool AbTestingIsAllowed(HttpContext context);
/// <summary>
/// Indicates if Analytics is allowed for the given request context.
/// If false, the visitor will be treated as the built-in Anonymous visitor
/// and all their activity will be assigned to the Anonymous visitor rather than the specific visitor.
/// No A/B testing or Personalization will be allowed either if this is false regardless of their
/// respective IsAllowed() outcomes.
/// In addition, no cookie will be sent to the visitor when this is set to false.
/// </summary>
/// <param name="context">Context of the request</param>
/// <returns>True if Analytics is allowed, otherwise false.</returns>
bool AnalyticsIsAllowed(HttpContext context);
/// <summary>
/// Indicates if Personalization testing is allowed for the given request context.
/// If false, the visitor will not see any personalized content.
/// </summary>
/// <param name="context">Context of the request</param>
/// <returns>True if Personalization is allowed, otherwise false.</returns>
bool PersonalizationIsAllowed(HttpContext context);Using these methods you can control per visitor whether or not the modules are active. Your implementation will need to be registered with Umbraco using the AddUnique() method, overriding the default implementation which enables all modules all the time. Make sure your composer runs after the Umbraco Engage composer by using the [ComposeAfter] attribute.
It could look something like this:
Member tracking when analytics is denied
When AnalyticsIsAllowed returns false, Engage treats the visitor as the built-in Anonymous visitor. Engage still records the pageview. Only the visitor attribution changes.
By default, a pageview from a logged-in member still carries that member's key when analytics is denied. The row is written either way. Denying analytics changes the visitor, not the member key.
Engage provides an opt-in setting to change this behaviour. When you enable it, Engage attaches the member key only to requests where analytics is allowed.
RequireAnalyticsPermissionForMemberTracking
The RequireAnalyticsPermissionForMemberTracking setting lives under Engage:Analytics:DataCollection and defaults to false. The setting and the rule for using it are documented on the configuration interface:
To enable the setting, add it to your appsettings.json:
Clearing member keys from existing pageviews
The setting applies going forward. It stops new pageviews from carrying a member key when analytics is denied. It does not change rows that Engage recorded before you enabled the setting.
To remove member keys from pageviews already collected, run the following script against your database during a maintenance window.
Tracking a visitor's Initial Pageview
Last updated
Was this helpful?