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.Business.Permissions.ModulePermissions.IModulePermissions
interface and override our default implementation.
This interface defines 3 methods that you will have to implement:
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 RegisterUnique()
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:
By changing the default module permissions to false a visitor is be tracked until they give their consent to the Analytics module. In that case, the module permission AnalyticsIsAllowed
will be set to true
.
Is the module permission set to true it is required to reload the current page as soon as the visitor has given consent. This needs to happen to track the current page visit the visitor has given consent on.
If no reload is performed the visitor's referrer and/or campaign information will not be tracked.
Calling the window.location.reload();
method is the preferred option, as this will preserve any referrers & query strings supplied in the current request.
This results in Umbraco Engage processing the current page visit & visitor correctly.
An example implementation using Cookiebot can be found in the security and privacy section.
Learn how the Umbraco Engage cookie works and how the functionality can be tested.
When visiting a website with Umbraco Engage installed you will get a unique cookie. This cookie allows for relating different page visits or sessions to the same visitor. It will also continuously serve the same variant of an A/B test.
By default the Umbraco Engage cookie has the name umbracoEngageAnalyticsVisitorId
. You can change the name in the configuration file.
The Umbraco Engage cookie:
Is a first-party cookie. This means it is set by the website itself and can only be used by the website itself. The cookie will not track you across the whole internet on all kinds of websites (like Facebook and LinkedIn).
Sets the HttpOnly
flag.
Sets the Secure
flag.
Is initialized with an expiry date of 365 days (depending on the settings in the configuration file) and has a sliding expiration. That means that if you revisit the website after 30 days, the cookie will reset and expire 365 days after that visit.
By default, all modules are initiated at the first page request. If you want to override this behavior, read the documentation about the different module permissions.