I’m working on a case where the client wants to implement a cookie banner only on the main site but has three subdomains. The client’s idea is to pass the cookie consent state from the main site to the subdomains, which are part of the same user journey. All the domains use the same GTM container.
From my understanding, the cookie consent state typically persists within the domain where it was accepted or rejected. However, the client wants to avoid anomalies, such as a user denying consent on Domain A but converting on Domain B (where there is no cookie consent banner).
Does anyone have a solution or technique to solve this? Or is this technically not possible?
A lot here depends on how the consent banner you use works.
The easiest way to transfer would be to add the necessary cookie data to the url when moving between domains and on the new domain take the values from the url and set them in the cookie. This can be done with regular JS - just add the values of the necessary cookies to the url when clicking, and on the new domain also through js to check the url and set them.
But you need to make sure that your consent banner doesn’t trigger before the url cookie is set on domain B, otherwise the user can change their mind and the cookie will be overwritten with a new one.
A more complex variant would be to use some user id based on it to store user cookies in some database (usually Firestore or Stape store) → pass this user id when switching between domains to the url and on the new domain by this user id from the database to take all the cookies you need and set them. This option will work better if you want to pass multiple cookies (e.g. click id of different platforms, browser id of different platforms, analytics cookies, etc.).
This all makes sense. However, given our limited knowledge on this, we went with OneTrust. We came to know that with OneTrust, we only have to scan the root domain, and it persists cookies across all subdomains without requiring any additional setup. That sounded more promising, and we successfully implemented it as well.