Case Study: Data Privacy Engineering
Implementing a compliant Google Tag Manager (GTM) setup while using Server Side GTM for minimizing data loss in Google Analytics.
Project Overview
With today's increasing focus on data privacy, digital data collection has to adapt. With GDPR and ePrivacy directives, you are not allowed to handle personal data nor place cookies in the user's browser, if the user has not granted the proper consent. Thus, we are now getting spammed on (almost) all websites with cookie consent popups that asks us to provide our consent, so the website can handle the data appropriately.
The Challenge
At Miinto (as for a lot of other ecommerce companies), this data privacy wave is a critical challenge for the digital data collection and general performance/experience of the platform. In fact, this trend had us face two different problems to solve.
- First of all, we needed to setup and implement a cookie consent management system. Here, we chose an external partner to handle the consents. However, we ourselves had to setup the cookie consent popup and implement control mechanisms for the related restrictions on tags and cookies in Google Tag Manager (GTM).
- Second of all, we needed to figure out how to prevent a damaging data loss in Google Analytics due to rejection of consent, which in it self will have critical impact on Miinto's ability to optimize the platform's performance and get insights on the users behavior on and usage of its sites.
The Approach & Solution
Given these challenges, we started the development of a compliant solution to respect the Miinto users' data privacy. Given the first challenge, we decided to use google consent mode to control the activation of any Google-related tags in GTM.
For none-Google-related tags, we designed a trigger template to make third-party tags (like Facebook, Hotjar etc.) to only get triggered, if the proper consent was granted by the user. Thus
For the second challenge, the issue is more complex. Luckily, Miinto has a fully-functioning GTM Server Side setup, which means the data hits are not send directly to the Google Analytics (GA) server. They are first send to Miinto's own server, which acts as an inbetween instance to handle these request before sending them to the proper endpoints (fx Google Analytics).
With this setup, I was able to write a custom template client to handle the data hits before forwarding them to the GA server.
In detail, this custom client is setup to do the following actions:
- First, the incoming request is checked for its consent status. This can be translated from the gcs parameter in the http request header. If the user of the hit has provided the proper consent, the hit is passed on to the regular GA client, which means it is handled as a regular GA request.
- However, if the user has not granted the proper consent, then the hit is handled by the custom template itself. This means, that the regular GA cookie will not be allowed to be written to the browser. As a result, we have to use a different user identifier to ascribe to the data hit. For this new identifier, we use the anonymized IP address of the data hit as well as the user agent string containing detailed information of the device of the hit. The combination and hashing of these data points is then used by the client as the new user id, which is added to the data hit before it is send to the GA server. This way, we are able to prevent any data loss, as none-consent users are properly anonymized before included in the GA data on the GA server.
The Results
The solution described was developed and depoyed across all 13 markets in the Fall of 2021. Shortly after deployment, the setup was accepted by the Danish GDPR authorities without any comments. Based on the post-deployment numbers, we can see that the solution has saved a +10% data loss, by applying the data anonymization approach. Finally, the setup also provides some interesting new insights, as we are now able to differentiate our users in different segments based on the consent, they have provided.
Want to connect?
Please feel free to reach out, if you are interested in knowing more about me and my projects or want to connect and hear how I might help your organization.