Consent and Privacy Engineering on a Multi-Product Hub
- security
- privacy
- consent
- gdpr
- architecture
A consent banner looks like a UI problem. You draw a box, add two buttons, and ship it. The part that decides whether the banner means anything is somewhere else entirely: the order in which scripts run, what each tag is allowed to do before the visitor has answered, where the answer is stored, and whether the legal pages describe the system that actually exists.
This post covers how we built that for norditco.com, the hub for Norditco's consumer products. It describes the consent gate in front of Google Tag Manager and GA4, the local storage model, the two legal pages, and how the hub relates to consent on product sites such as Learn Persian with Sepideh. It also lists the limitations we have not closed yet.
One boundary up front. This is an engineering write-up. It describes what our code does and what our public pages say. It is not legal advice, and nothing here tells you what your own site needs. If you operate under GDPR or ePrivacy rules, your counsel decides that.
Why a hub makes this harder
Norditco ships several products on different hosting setups. The hub at norditco.com is a single-page React app that describes the company, lists the products, publishes news and engineering writing, and serves as the entity root for what we call the Discovery Mesh. Each product has its own host, its own deploy path, and in some cases its own analytics and its own banner.
That produces three constraints that a single-product site never faces.
- Scope. A consent decision made on
norditco.comis a decision about that origin. Browser storage is per origin, so it does not carry over to a product subdomain, and we do not pretend it does. - Consistency. A visitor who moves from the hub to a product site should meet the same posture. Optional measurement is off until they say otherwise, and saying no is as easy as saying yes. The implementations differ, but the behavior should not.
- Honest documentation. Legal pages that describe a different system from the running one are worse than no pages. They need to be tied to the code, and they need to be crawlable so that both people and machines can find them.
The design in one paragraph
The hub sets Consent Mode defaults before the Tag Manager snippet runs. For visitors in the EEA, the UK and Switzerland, all four consent signals start as denied. A React banner offers Accept and Reject with equal weight. The visitor's answer is written to localStorage, pushed to Google's consent API as an update, and replayed on every later page load. Everything else (tags, triggers, GA4 configuration) lives inside the tag manager and respects those signals. The cookie policy and privacy policy describe exactly this behavior and link to each other and to the banner.
Step one: defaults before the tag
The ordering is the whole point. Consent Mode only works if the default state is declared before the tag manager loads, because tags read the consent state when they initialize. If the container loads first, early tags can fire with whatever state the library assumes.
In index.html, a small inline script runs ahead of the Tag Manager snippet. It initializes dataLayer, defines gtag, and declares two defaults.
The first default is region-scoped. For a list of EEA member states plus the UK, Switzerland, Iceland, Liechtenstein and Norway, it sets ad_storage, ad_user_data, ad_personalization and analytics_storage to denied, with a short wait_for_update window of 500 milliseconds. That window gives the application a moment to replay a stored choice before tags make their first decision.
The second default is global and sets all four signals to granted. Because Consent Mode resolves the most specific matching default, visitors outside the listed regions get the global default, and visitors inside get the denied one.
We want to be precise about what this means, because it is easy to overstate. Default-deny holds in the regions we listed. It is not a worldwide default. That is a deliberate scoping choice that matches what the cookie policy states, which says that in the EEA, UK and Switzerland non-essential analytics cookies load only after Accept. We did not extend the same rule to every visitor, and we do not claim we did.
The Tag Manager container itself still loads for everyone. That is how Consent Mode is designed to work. The container is present, the consent state gates what tags are permitted to do with storage and identifiers, and the container ID stays in the page source where it belongs. We deliberately keep it out of this post.
Step two: the decision flow
The runtime has two moments. The first is page load, when we check for a stored answer. The second is the click, when the visitor gives one.
A few details in this flow are worth stating.
Replay runs through the same function as a fresh click. On mount, the component reads the stored value and, if it is valid, calls applyConsent with it, then keeps the banner hidden. There is one code path that moves consent state, not one for first visits and another for returning ones. That removes a class of bugs where the stored state and the live state drift apart.
Unreadable storage is treated as no answer. Reading localStorage is wrapped in a try and catch. In private browsing modes or with storage blocked, the read fails, we treat it as "no stored choice", and the banner shows. Writing is wrapped the same way. If the write fails, consent still updates for the current page view, but the visitor will be asked again next time. We prefer asking twice over assuming yes.
Accept and Reject are the same size, in the same row. Both are real buttons with the same padding and the same prominence in the layout. The component comment says it plainly: reject is as easy as accept. We treat that as a testable property of the interface, not a design preference.
The dialog is labelled. The banner uses role="dialog" with an accessible title and description, and it links to both policy pages from the body text. A consent request that a screen reader user cannot parse is not a meaningful request.
Step three: what "grant" and "deny" actually change
applyConsent is small on purpose. It makes sure gtag exists, then sends one consent update that sets ad_storage, ad_user_data, ad_personalization and analytics_storage to the same state. Accept maps all four to granted. Reject maps all four to denied.
We keep the four signals coupled for now. The banner offers one analytics choice, not a category panel, so there is no UI that could justify granting one signal and denying another. If we add categories later, this function is where the mapping would split, and the policy text would need to change in the same release.
After the update, the function persists the choice and pushes a cookie_consent_update event into dataLayer carrying the value. That event exists for the container: it lets us build triggers that react to a change, and it gives us a clean marker when debugging a tag in preview mode. The event carries only the choice, with no identifiers.
The same module exposes a trackEvent helper that pushes custom events for container triggers. It does not call GA4 directly. Application code describes what happened, and the container decides what to do about it under the current consent state. That separation matters for privacy review. There is one place, the tag manager, where all measurement is configured and audited, and the React code has no direct line to an analytics vendor.
Step four: where the choice lives
The visitor's answer is stored in localStorage under a versioned key. The key follows a norditco_cookie_consent_v<N> pattern, and the value is one of two strings, accepted or rejected. Anything else is ignored on read.
Three decisions sit behind that.
Local storage instead of a cookie. The record of a consent decision should not itself be a tracking mechanism. A localStorage entry is never sent to our servers with a request, has no expiry negotiation, and cannot be read by the tag manager as an identifier. The component documentation says it directly, that the choice is stored locally and is not a tracking cookie.
A versioned key. The _v1 suffix is how we change the question later. If we add categories, or the meaning of "accepted" changes, we bump the version. Old records stop matching, every returning visitor sees the new banner, and we never reinterpret an old answer under a new meaning. It is a simple piece of insurance against stale consent.
Strict parsing. Only two exact strings count as a stored choice. A corrupted or hand-edited value reads as "no answer". Failing toward asking is the right default.
The tradeoff is that the stored record lives on one origin and one browser profile. Clearing site data resets it. The banner copy tells visitors this directly, that clearing site data for norditco.com is how to change their mind, which is accurate for the current build. It is also a limitation, and we cover it below.
Step five: legal pages as engineered surfaces
The hub ships two policy pages, /cookie-policy and /privacy. We treat them like any other route.
Both are real pages in the application, not PDFs and not modals. Each sets a canonical URL, a page title and a meta description from the same translation layer as the rest of the site, and each emits JSON-LD with a breadcrumb back to the home page and a WebPage node whose isPartOf references the site's website entity. They carry a modified date in the structured data and a visible "last updated" line in the page body.
The text lives in the i18n files under cookiePolicy and privacyPolicy, next to the cookieConsent strings the banner uses. That placement has a practical benefit: the banner copy, the cookie policy and the privacy policy sit in the same file, so a reviewer can read all three in one diff. When someone changes how analytics behave, the diff shows the code, the banner text and the policy text together, or it shows that one of them was missed.
What the pages commit to is intentionally modest. The cookie policy explains what cookies are, how the site uses them (preferences, secure operation, anonymous usage information), and how to manage them in the browser. It states that in the EEA, UK and Switzerland, non-essential analytics cookies load only after Accept. The privacy policy names the controller, lists categories of data, says analytics runs through Google Tag Manager and Google Analytics and is consent-based for those regions, covers retention at the level of "according to Google Analytics settings", and lists data subject rights with a contact route. We describe the system and point to contacts. We do not try to cover every jurisdiction or make statements that code cannot back up.
Step six: how this fits the Discovery Mesh
The hub is the entity root in our Discovery Mesh. Privacy pages fit into that structure for a plain reason: they are part of what makes an organization identifiable and verifiable.
A crawler or a person evaluating Norditco should be able to find, from the home page, who publishes the products, which entity controls personal data, and what the cookie posture is. So both policy pages are linked from the footer and the banner, have canonical URLs, sit in the sitemap, and carry structured data that ties them to the site entity. They are crawlable legal surfaces, as ordinary and as indexable as any other page.
We do not use them to make claims for search or for language models. They describe the system for the people affected by it. Machine-readable metadata is there so that the page is correctly identified, dated and attributed, which are the same four questions the rest of the mesh answers.
Step seven: the multi-product picture
Here is how the privacy surfaces relate across the hub and a product. The diagram is intentionally about boundaries, since the boundaries are what we have to get right.
Each box has its own state. The hub's stored choice does not apply on the product site, and the product site's choice does not flow back. What is shared is the set of principles and the vocabulary, not the storage.
What the product side does
The Learn Persian with Sepideh web app runs on its own origin and has its own first-party banner. Its public news posts describe the behavior: optional analytics and advertising-related storage stay off if the visitor declines, necessary storage stays on, lessons work identically either way, and the preference is saved on the device and resets when browser data is cleared. A later post covers the move to a banner built and served as part of the site rather than loaded from an outside service, which also removes one third-party script from the path that shows the banner.
The Android app is a separate surface again. It has an in-app consent screen on first launch and lets the user review and change the choice from within the app. A web visitor and an app user answer separate questions in separate places, and the public posts say so, pointing to the app's own settings for app-side options.
We chose not to unify these into a single cross-product consent record. A shared identifier across origins would be the more convenient engineering and the worse privacy design, since it needs exactly the kind of cross-site identifier a consent system is supposed to constrain. We accept the cost, which is that someone who uses both the hub and a product site may see two banners.
What we do share
The sharing happens at the level of rules, not data.
- Optional measurement is off until the visitor agrees, in the regions where we scope it that way.
- Reject is as prominent as Accept, with no dark patterns and no pre-ticked states.
- The product works either way. Declining never removes content or features.
- The choice is local and changeable. It lives on the device and is not a tracker.
- Policy pages are public, canonical and dated.
These five rules are the checklist we use when we add a product or change a banner. Implementations differ by framework and host, but any product that cannot meet the list does not ship.
What we test
A consent system has a few properties that can be checked mechanically, and we try to treat them that way.
- No analytics requests before an answer, in default-deny regions. In a fresh profile with a European region, the network panel should show the container loading but no analytics collection calls until Accept.
- Reject persists. After Reject and a reload, the banner stays hidden and the consent state is denied on the second load.
- Accept persists. The same test in the other direction.
- Storage failure degrades to asking. With storage blocked, the banner reappears and nothing breaks.
- Version bump re-prompts. Changing the key version invalidates old records.
- Policy parity. The statements in the cookie policy and privacy policy about regions and analytics match the defaults in
index.html. This is a human review step that we tie to the same pull request as the code change.
We use Tag Manager preview mode to check that tags observe the consent state at the moment they fire, and we check the cookie_consent_update event arrives with the expected value.
Known limitations
A write-up like this is more useful with its gaps listed.
There is no reopen control yet. Once the banner is dismissed, the only route to change the answer is clearing site data, and the banner text says so. A persistent "cookie settings" link in the footer that clears the stored value and re-shows the banner is the obvious fix. We have not shipped it, and it should exist.
Replay timing. The stored choice is applied when the React app mounts, which is after the inline defaults and the container have started. The 500 millisecond wait_for_update window is meant to cover that gap, but it is a timing assumption, not a guarantee. On a slow device, a returning visitor who accepted could briefly be treated as denied before the update arrives. That fails in the privacy-protective direction, though it costs us some measurement. Moving the replay into the inline script, ahead of the container, would remove the dependency on mount timing.
Regional scoping is a list. The region list in the defaults is maintained by hand. It needs a review whenever the set of covered jurisdictions changes, and the policy text needs to follow.
Policy dates are manual. The "last updated" lines and the structured data modified dates are edited by hand and have drifted between the two pages. Generating them from one source would be better.
Retention is described at a high level. The privacy page defers analytics retention to the analytics product's settings. That is accurate, and it is also less specific than a visitor might want.
None of these are hidden, and each one is a concrete engineering change rather than a legal question.
Principles we would repeat
If we reduce the build to a few rules that transfer to other multi-product setups, they are these.
- Declare defaults before anything can read them. Consent state is an initialization concern, not a UI concern.
- One function moves consent state. Replay and click share a path.
- Keep the record of consent from becoming a tracker. Local, versioned, strictly parsed.
- Route all measurement through one governed layer. Application code emits events and the container decides.
- Scope claims to what the code does. Region-specific defaults get region-specific statements.
- Treat legal pages as routes. Canonical, dated, linked, translatable, and reviewed in the same diff as the behavior.
- Share rules across products, not identifiers. Coherence comes from principles, not from a cross-site ID.
The banner is the visible tenth of the work. The rest is ordering, storage, vocabulary and honest documentation, and those are things an engineering team can build, test and keep accurate.
You can read the published pages yourself at norditco.com/cookie-policy and norditco.com/privacy, and see the product-side behavior at Learn Persian with Sepideh.
