Machina

Machina — Marketing that moves numbers.

Reach out today

Chapter 10·Part III · Implementation: Correctness and Architecture

Privacy and Consent by Design

Privacy work on an analytics stack fails most often not because a team ignores the law but because it treats privacy as a document. A policy page gets written, a cookie banner gets bolted on, a checkbox gets ticked in a vendor console, and everyone declares the property compliant. None of that changes what the browser sends, what GA4 stores, or what flows onward to Google Ads. This chapter treats privacy as a property of the running system: a set of signals the code emits, a set of fields the code refuses to emit, and a set of defaults that hold until someone deliberately changes them. The audit and reconstruction of GA4 property 534525683 (measurement ID G-WH410Z73V1) produced a posture I can describe and defend on engineering grounds, sized to what {COMPANY} actually is: a single local pest-control operator serving Monterey, Santa Cruz, San Benito, and Santa Clara counties, with no EEA presence, no online transaction, and roughly 500 sessions a month.

The temptation at this scale is to do nothing, on the theory that a small California business selling termite and rodent treatment locally has no meaningful privacy exposure. Traffic volume does not answer that question, and this chapter does not either. Which privacy laws apply to a business turns on facts such as its revenue, how it handles and shares personal information, and where the people it reaches are, and that assessment belongs to the business and its advisers. What this chapter can establish is the engineering. Consent signals are part of how Google's tags and advertising systems decide what data they may use, including the offline-conversion data that Chapter 11, "The Offline-Revenue Loop," depends on. Consent Mode earns its place in this build as infrastructure, not as compliance theater.

The regulatory context: what the build records and what it leaves open

{COMPANY} operates within the United States, in California, selling a physical service to customers in four adjacent counties. Three legal regimes come up whenever a website like this is discussed: the California Online Privacy Protection Act (CalOPPA), the California Consumer Privacy Act as amended by the California Privacy Rights Act (CCPA/CPRA), and the GDPR with the ePrivacy consent rules. None of them is settled by a site's traffic. This section records what the official sources say each one turns on and what the build did. It is not a legal opinion, and none was obtained for this property.

CalOPPA (California Business and Professions Code sections 22575 to 22579) addresses operators of commercial websites that collect personally identifiable information from California residents. Its subject is a conspicuously posted privacy policy that discloses the categories of information collected, the categories of third parties it is shared with, and how a user can review or request changes. This site runs GA4 and takes contact-form leads (name, email, phone and address in the contact_submissions row), so the build records a published privacy policy as an owner deliverable. A policy is a disclosure. It does not change what the code sends, and it says nothing about consent gating.

The CCPA, as amended by the CPRA, applies to a for-profit "business" that meets at least one of its thresholds. As adjusted by the California Privacy Protection Agency from January 1, 2025, they are annual gross revenue above $26,625,000; buying, selling or sharing the personal information of 100,000 or more California consumers or households a year; or deriving 50 percent or more of annual revenue from selling or sharing personal information (California Privacy Protection Agency, CPI adjustment of monetary thresholds, cppa.ca.gov/regulations/cpi_adjustment.html; the agency's FAQ at cppa.ca.gov/faq sets out the coverage questions). Session counts settle none of these tests. A GA4 session is not a consumer or a household, and the revenue and data-sharing tests turn on business records an analytics property does not hold. An earlier draft of this study treated the property's low traffic as an exemption; that reasoning is withdrawn. Whether the statute applies is a fact-specific assessment for the business, and nothing in this build depends on its answer.

Global Privacy Control (GPC) is a browser-emitted signal. California's regulations treat it as a request to opt out of sale or sharing for businesses the CCPA covers (California Code of Regulations, title 11, section 7025), so whether it applies here follows from the coverage assessment above, which this study does not make. The build does not read GPC today. I record that as an open item for the owner rather than as a reasoned exemption, so a future reviewer sees it was considered. If the assessment calls for it, the consent plumbing described below is the natural place to wire it.

The GDPR's territorial scope is set by its Article 3. The European Data Protection Board's guidelines on that article describe two tests: whether the organisation has an establishment in the Union, and, if it does not, whether it offers goods or services to people in the Union or monitors their behaviour there (EDPB, Guidelines 3/2018 on the territorial scope of the GDPR (Article 3)). A single page view from Europe is not the test, and neither is how likely a regulator is to look. {COMPANY} has no establishment in the Union and markets a physical service in four California counties; how the targeting and monitoring tests apply to its site is a question for the business and its advisers. On the engineering side, behaving conservatively toward visitors from the EEA, the UK and Switzerland costs almost nothing, and it is what Google's EU user consent policy expects of sites that use Google's advertising and measurement products with those users. So the build sets denied defaults for those regions.

The record, then: the build lists a published privacy policy as an owner deliverable and sets region-scoped consent defaults for the EEA, the UK and Switzerland. Whether the CCPA, its GPC rules or the GDPR apply to the business is left open, as a fact-specific assessment outside this study. Everything else in this chapter is engineering chosen because it pays for itself in data quality and in what Google's systems will accept. None of it is offered as evidence of compliance with any law.

The reconstruction added Google Consent Mode v2 to the gtag configuration. The critical design decision was to make it region-scoped rather than global, so that the tool US analytics that funds the whole measurement program keeps working at full fidelity while European users receive a conservative default. The implementation issues two gtag('consent', 'default', ...) calls before the config call, in this order:

gtag('consent', 'default', {
  ad_storage: 'granted',
  analytics_storage: 'granted',
  ad_user_data: 'granted',
  ad_personalization: 'granted',
});

gtag('consent', 'default', {
  region: [
    'AT','BE','BG','HR','CY','CZ','DK','EE','FI','FR','DE','GR',
    'HU','IE','IT','LV','LT','LU','MT','NL','PL','PT','RO','SK',
    'SI','ES','SE','IS','LI','NO','GB','CH',
  ],
  ad_storage: 'denied',
  analytics_storage: 'denied',
  ad_user_data: 'denied',
  ad_personalization: 'denied',
  wait_for_update: 500,
});

The first call sets a global default of granted across all four Consent Mode v2 signals. The v2 signals are ad_storage and analytics_storage (carried over from v1) plus ad_user_data and ad_personalization (the two parameters Google's consent mode documentation asks implementers to send in addition to ad_storage and analytics_storage). Because this default is global and granted, a visitor in Salinas or Monterey loads the page, gtag writes the _ga cookie, GA4 receives full un-modeled hits, and nothing about the US measurement changes. This preserves the ga_client_id capture rate the reconstruction worked to protect, discussed in Chapter 9, "Identity, Attribution, and Value."

The second call scopes a denied default to 32 region codes: the 27 EU member states, the three additional EEA states (Iceland, Liechtenstein, Norway), the United Kingdom, and Switzerland. For a browser whose Google-resolved region matches one of these codes, all four signals default to denied. GA4 then sends cookieless, modeled pings for that user rather than storing identifiers, and no data about that user propagates to Google Ads. Region matching happens on Google's side from the request, so the site needs no IP-geolocation library and no server round trip to decide which default applies.

wait_for_update: 500 is the parameter that keeps this from silently dropping European hits. It tells gtag to hold tags for up to 500 milliseconds after page load to see whether an explicit consent update arrives, for instance from a consent-management platform. {COMPANY} runs no such platform (I explain why below), so in practice the 500-millisecond window expires and the denied default stands. The parameter is there so that if a banner is ever added, the wiring already respects its answer without a rebuild. The team inspected the dataLayer after loading the page to confirm the global default resolved to granted, verifying that the ordering of the two calls did not accidentally deny US traffic.

Why the US default is granted, and the correction the audit made

An early draft of the adversarial audit flagged the absence of Consent Mode as a compliance gap and implied the US site legally required a denied-by-default posture and a cookie banner. The verification pass in Chapter 4 separated two questions the draft had merged. The first is a platform requirement: Google's EU user consent policy and its consent mode documentation expect sites that reach users in the EEA, the UK and Switzerland to collect consent and pass the user's choices to Google's tags (Google, "Consent mode overview", developers.google.com/tag-platform/security/concepts/consent-mode). The second is a legal question about what any statute requires of this site. The verification pass could not settle that question, and this chapter does not. The engineering choice follows from the first question only. A denied-by-default global posture would turn every US hit into modeled estimation and discard the identifier resolution and attribution accuracy the rest of the build depends on, so the US default is granted. The region-scoped denial follows Google's documented expectation for those regions and enables the Ads-side behavior described next. If the owner's own assessment calls for a banner or a different US default, the wait_for_update wiring above already accepts it.

The June 2026 control-point shift

There is a forward-looking reason the region scoping is worth carrying even though {COMPANY} has no European customers. Google has announced that, starting June 15, 2026, Google Analytics moves to Consent Mode as the control for how its data is used for advertising. Google signals will then control only the association of Analytics data with signed-in user information, and the ad_personalization consent signal is to become the sole control for ads personalization later in 2026, on dates Google had not yet announced when this was written (Google Analytics Help, "Updates to Google Analytics Data Controls", support.google.com/analytics/answer/17016975). For this property, whose US population defaults to granted on all four signals, the expected effect is that when the Google Ads link is created (deferred in this build, see Chapter 7, "Conversion Architecture"), US data is not held back by consent state, while visitors in the denied regions are. Building the consent defaults now means the Ads link, when it lands, does not need a second pass to become consent-aware.

The offline-revenue loop in Chapter 11 rests on Enhanced Conversions for Leads, the mechanism that matches an offline booked job back to a click using a hashed identifier from the lead. Google requires Consent Mode signals to be present and correct for Enhanced Conversions to accept and use that data. ad_user_data is the consent type that tells Google whether the user agreed to user data related to advertising being sent to Google. Without a Consent Mode configuration emitting that signal, Google's systems have no consent state to read for that data and may decline the match. The consent defaults added in this phase are therefore not a parallel privacy track. They are load-bearing for the revenue measurement the whole engagement is meant to produce. This is the sharpest illustration of the chapter's thesis: the signals that tell Google's tags what a European visitor chose are the same signals Google's systems read before using lead data for conversion matching. They communicate consent state to Google. They do not, on their own, establish a legal basis for collecting or uploading anything; that question sits with the owner.

PII discipline: the clean posture and the enum rule

GA4's terms of service forbid sending personally identifiable information into events. Google's definition is broad: no names, emails, phone numbers, street addresses, or any free-form field that could carry them, in any event parameter, user property, or custom dimension. The prohibition is absolute and enforcement is blunt; Google reserves the right to delete data or terminate a property that violates it. The engineering obligation is to guarantee, at the code level, that no such value can reach the tag or the Measurement Protocol payload.

The audit found the property already clean on this front, and the verification pass confirmed it: the existing Measurement Protocol payload carried no PII. The contact_submissions database row holds the customer's name, email, phone, and address, but the server-side generate_lead event described in Chapter 6, "The Server-Side Measurement Protocol," sends only non-identifying fields: client_id, currency, a per-service value, form_source, service_type, session_id, engagement_time_msec, and ip_override. The IP override is a documented Measurement Protocol field used for geolocation. An IP address can identify a household, so it is listed here alongside the identifying data; how Google handles it after receipt is set by Google's own documentation and terms, which this study did not test. The PII stays in PostgreSQL, behind the admin auth described in Chapter 15, "Access and Permissions Model," and never crosses into analytics. Preserving that separation was a constraint on every payload change, not an afterthought.

The subtle risk on a property like this is not the fields a developer sends on purpose. It is a free-text field that leaks PII by accident. The reconstruction registered a custom dimension error_message, and a naive implementation of a form_error event would populate it with whatever the browser or server produced, which could include a user's typed email or a validation string echoing their input. That is precisely how well-meaning error instrumentation becomes a PII violation. The defense is an enum rule: the code sends error_message only from a bounded, closed set of machine codes such as server_error, network_error, validation_error, never raw user text and never a raw exception string. Because the domain of the parameter is a fixed vocabulary the code controls, the dimension is safe to register and safe to report on. Chapter 8, "Event Taxonomy and Custom Dimensions," specifies the enum and the rationale in full; the point here is that PII discipline is enforced by constraining what a parameter can contain at the point of emission, not by hoping the values stay clean. A closed vocabulary is a privacy control as much as a data-quality one.

Google Signals: the privacy and reporting tradeoff

Google Signals was already disabled on the property when the audit began, and the reconstruction confirmed the setting and left it off. That was the correct call for reasons that are equal parts privacy and reporting, and the decision deserves its reasoning on the record because teams often flip Signals on reflexively for "better demographics."

Google Signals associates GA4 events with signed-in Google users who have Ads Personalization enabled, which unlocks cross-device attribution and demographic and interest reporting. It also introduces a privacy surface: the property begins leaning on Google's account-level data about identifiable individuals, which raises the consent bar and the disclosure burden. The verification pass in Chapter 4 corrected an overstated claim about Signals, and this edition narrows that correction further. Thresholding is GA4's withholding of data where user counts are low enough that an individual might be identified. Google documents that data may be withheld from a report, exploration or API call that includes demographic data, and from search-query rows when there are not enough users (Google Analytics Help, "[GA4] About data thresholds", support.google.com/analytics/answer/9383630). Google does not describe a blanket suppression of every segmented row, so it would be wrong to say that enabling Signals would hide all of this property's by-service and by-county Explorations. What can be said is narrower: with 401 active users over 30 days, any demographic breakdown this property ran would sit in the low-count range where thresholds are likely, and the demographic and cross-device data Signals adds would be thin at this volume. Leaving Signals off keeps that trade off the table and avoids the extra disclosure. The decision stays; the mechanism is stated as Google documents it. Chapter 9 develops the attribution consequences; the privacy reading is that Signals is a cost with no matching benefit at this scale.

A defensible posture, sized to the business

The posture the reconstruction leaves behind is deliberately proportionate, and each element traces to a reason rather than to a template.

The build ships a granted-by-default global Consent Mode v2 configuration so US analytics runs at full fidelity, with a denied default scoped to 32 EEA, UK, and Switzerland region codes and wait_for_update: 500, kept as cheap forward-compatibility and as the consent basis that Enhanced Conversions for Leads will require. It enforces PII discipline structurally: identifying data stays in PostgreSQL, the analytics payloads carry none, and the one free-text-shaped parameter is constrained to a closed enum at emission. It leaves Google Signals off because, at 401 monthly users, the demographic and cross-device data it adds would be thin and any demographic breakdown would likely meet data thresholds. It does not build a consent-management platform or a cookie banner. That is a scoping choice for this engagement, made on engineering grounds and open to revisit if the owner's legal assessment calls for one. It records the privacy policy as an owner deliverable and treats it as content.

The through-line is that every privacy decision here is an engineering decision with a regulatory footnote, not the reverse. The consent signals exist because they gate a revenue pipeline. The PII rule exists because a leaked field terminates a property. Signals stays off because it adds little at this volume. A business this size does not need privacy theater, and it cannot afford to skip privacy engineering, because the engineering is what makes the measurement both trustworthy and, when the Ads link arrives, permitted to work. Chapter 14, "Anti-Pattern Catalog," files the inverse of each of these choices, the denied-by-default US tag, the raw error string, the reflexive Signals toggle, as the mistakes this posture was built to avoid.

We use cookies and analytics to understand how visitors use our site and improve your experience. Privacy Policy · Do Not Sell or Share My Personal Information