Sub topic 15
Privacy, Consent, and Common Mistakes
This chapter assumes you have a GA4 property with lead and purchase events already sent and marked as key events. It also assumes you can read a gtag.js snippet and use DebugView. The chapter covers two things. The first is how privacy rules and consent choices change the data your key events collect. The second is the setup mistakes that most often corrupt lead and sale numbers.
Why privacy affects key event data
Key events only count what GA4 is allowed to collect. If a visitor declines analytics storage, the visit may be missing from your reports or only partly recorded. A lead or sale can happen with no matching event. Reports then undercount, and the gap changes with the country, the consent banner design, and the browser.
Two separate duties apply to you:
- Consent: Many regions require permission before you store identifiers such as cookies for analytics or advertising. The rules differ by region, so check with whoever handles legal compliance for your site.
- No personal data in your own data: Google's terms for Analytics prohibit sending personally identifiable information (PII). Examples are email addresses, phone numbers, full names, and street addresses. This duty applies whether or not a visitor gave consent.
Consent Mode
Consent Mode lets your site tell Google tags what the visitor has agreed to. The tags then adjust their behavior. It uses four consent signals:
| Signal | What it controls |
|---|---|
| `analytics_storage` | Whether GA4 may use cookies to measure visits |
| `ad_storage` | Whether advertising cookies may be stored |
| `ad_user_data` | Whether user data may be sent to Google for advertising |
| `ad_personalization` | Whether data may be used for personalized advertising |
When analytics_storage is denied, GA4 can send cookieless pings that carry no persistent identifier. Where behavioral modeling is available and your property meets its data requirements, GA4 uses those pings to estimate some of the missing activity. Modeled data fills part of the gap, not all of it. Treat counts for denied traffic as estimates.
The defaults must be set before any Google tag loads. Update them when the visitor makes a choice.
// Place this before the gtag.js or Tag Manager snippet
window.dataLayer = window.dataLayer || [];
function gtag(){ dataLayer.push(arguments); }
// Default: everything denied until the visitor chooses
gtag('consent', 'default', {
analytics_storage: 'denied',
ad_storage: 'denied',
ad_user_data: 'denied',
ad_personalization: 'denied'
});
// Call this from your consent banner when the visitor accepts
function onConsentAccepted() {
gtag('consent', 'update', {
analytics_storage: 'granted',
ad_storage: 'granted',
ad_user_data: 'granted',
ad_personalization: 'granted'
});
}If you use Google Tag Manager, most consent management platforms have a template that does this. Your GA4 event tag should then respect the consent state through its built-in consent checks.
Keeping personal data out of parameters
Personal data usually gets into GA4 by accident. These are the common routes:
- A form field passed as a parameter. A developer adds
emailto thegenerate_leadevent "for debugging" and it stays in production. - Query strings in URLs. GA4 collects the page address automatically. A confirmation URL such as
/[email protected]sends the email inpage_location. - Item names or transaction IDs that contain names. An ID such as
ORDER-ANA-SMITH-001is personal data. - User IDs built from email addresses. If you set a
user_id, use an internal identifier that cannot be reversed into a person's details.
Fix the source. Change the form's redirect so it carries no personal values, and use an order number that is random or sequential. Deleting data afterward is harder. Event data you already sent can be deleted only through the property's data deletion tools, and some uploaded data cannot be removed at all.
Common mistakes and how to find them
Most key event problems fall into a short list. Each can be found in DebugView or in a report.
| Mistake | Symptom | Fix |
|---|---|---|
| Purchase fires on every page load of the confirmation page | Sales higher than the order system shows | Send a unique `transaction_id` and fire the event once |
| `value` sent without `currency` | Revenue reports show 0 or miss the revenue | Always send an ISO 4217 code such as `USD` with a numeric value |
| `value` sent as text, such as `"$59.98"` | Value ignored or wrong | Send a plain number: `59.98` |
| Event fires on button click, not on success | Failed or invalid forms count as leads | Fire after the server confirms the submission |
| Event name typed with different case, such as `Generate_Lead` | Two separate events appear | Event names are case-sensitive. Use one exact spelling |
| Event marked as a key event before it ever arrived | The event is missing from the Admin list | Send the event first. It can take up to about a day to appear |
| Too many events marked as key events | Noisy reports and a hit limit | Keep only real business outcomes. A standard property has a limit on key events |
| Internal traffic counted | Test leads and staff orders inflate counts | Define internal traffic and activate the data filter |
| Counting method not reviewed | One visitor adds many leads in a session | Choose once per event or once per session on purpose |
| Custom parameters not registered | Parameter missing in reports | Register it as a custom dimension or metric |
Duplicate sales in detail
Duplicates are the most costly error because they inflate revenue. They come from three sources:
- The visitor reloads the confirmation page or returns to it from a bookmark.
- Both a hard-coded gtag snippet and a Tag Manager tag send the same purchase.
- A single-page app fires the event again when a route changes.
A transaction_id lets GA4 recognize that two purchase events describe the same order. It is a safeguard. It is not a reason to skip fixing the cause. Also store a flag, such as a cookie or a server-side "already reported" field, so the event is sent once per order.
// Send the purchase only once per order, even if the page reloads
function sendPurchaseOnce(order) {
var key = 'ga4_purchase_sent_' + order.id;
if (window.localStorage.getItem(key)) {
return; // already reported
}
gtag('event', 'purchase', {
transaction_id: order.id,
value: order.total,
currency: order.currency,
items: order.items
});
window.localStorage.setItem(key, '1');
}
sendPurchaseOnce({
id: 'T_12345',
total: 59.98,
currency: 'USD',
items: [
{ item_id: 'SKU_123', item_name: 'Trail Shoes', price: 59.98, quantity: 1 }
]
});This code assumes that gtag is already defined on the page. The local storage check is per browser, so a visitor who opens the confirmation link on another device can still send it again. The transaction_id covers that case.
Changes are not retroactive
Marking an event as a key event, or changing its counting method, applies from that moment forward. Past data is not recalculated. Write down the date of each change. When a trend jumps on that date, you will know the cause is the setting and not the audience.
A pre-launch checklist
Before you rely on the numbers, check these items in order:
- Defaults are set before any Google tag loads, and the banner updates them.
- In DebugView, a test lead and a test order each produce exactly one event.
- The
purchaseevent showstransaction_id,value,currency, anditems. - No parameter or URL in the events contains personal data.
- Test traffic is excluded by an internal traffic filter or a separate stream.
- Each key event has the counting method you chose on purpose.
- You have compared a week of GA4 sales with your order system and can explain the difference. Expect a gap from denied consent, ad blockers, and users who leave before the tag fires.
Exercise
A site's confirmation page URL is /thanks?order=1001&[email protected]. The purchase event itself has no personal data. Is anything still wrong, and what do you change?
Show answer
Yes. GA4 collects the page address automatically as page_location, so the email address is sent to GA4 inside the URL. Change the redirect so the URL carries only a non-personal value, such as /thanks?order=1001, or no query string at all.
Exercise
Reported revenue is double the order system total. DebugView shows two purchase events per order, both with the same transaction_id. Name two likely causes and one prevention step for each.
Show answer
Likely causes are (1) the confirmation page reloads or is revisited, and (2) a hard-coded gtag snippet and a Tag Manager tag both send the purchase. Prevent the first by firing the event once per order, for example with a stored "already sent" flag. Prevent the second by keeping only one sending method and removing the other.
Exercise
You switch a lead key event from "once per event" to "once per session" today. Will last month's report change?
Show answer
No. The counting method applies to data collected after the change. Past data keeps the old counting. Record the change date so you can explain any shift in the trend.