How to integrate 3rd party consent tool with Piwik PRO anonymous tracking?

Update: There’s a dedicated helpcenter article describing needed steps:


Old version of the guide is available below:

This integration may be also used if for some reason you want to use 3rd party consent manager in a similar way to the native integration between Piwik PRO Tag Manager and Consent Manager.

What we want to achieve?
After entering website, user sees a non-Piwik PRO Consent Manager. Even though a 3rd party consent system is used, all analytics events are gathered with a random ID that is dropped after 30 mins of inactivity. In addition to that, there is no fingerprint stored, IP is fully masked, and geolocation shows at most the country.

This setup makes it possible to access all the relevant session metrics, traffic sources or even conversion attribution - also when the consent is not given. After the user gives the analytics consent, all the previously tracked data is enriched, so Piwik PRO sets a cookie, starts storing fingerprints, unmasks IP address (with possible masking of a few octets) and presents a full set of geolocation information.

Preliminary steps

  1. Tag manager snippet is loaded on each page view (prior and after the consent)
  2. Piwik PRO Analytics tag is set to require consent for Analytics category (that’s the default setting)
  3. Website is set to use Consent Manager, data is stored prior the consent with a use of a 30min ID, custom consent form is enabled (this setting will disable the standard built-in consent manager)

With such a setup, all the data should be tracked anonymously before and after consent.

Get all the data after a consent is given
To improve it and get all the data after the consent, we can utilize Consent Manager API. So, just after the user agrees to analytics, execute this piece of code:

ppms.cm.api('setInitialComplianceSettings', {consents: ['analytics']}, function(){}, function(){});
ppms.cm.api('setComplianceSettings', {consents: {analytics: {status: 1}}}, function(){}, function(){});

This code will set the consent status in the first party cookie, send a data enrichment ping to make sure that the session has all the relevant information, and store consent statistics event to further analyze consent opt-in rate.

2 Likes

A post was split to a new topic: GTM and Piwik PRO anonymous tracking?