Sub topic 15
Privacy, Consent, and Common Mistakes
Assume you have a GA4 web data stream installed, Editor access to the property, and basic knowledge of forms, checkouts, Reports, and Admin. This chapter focuses on protecting users and keeping lead and sale data trustworthy.
Protecting personal data
GA4 event parameters should describe an action, not identify a person. Do not send names, email addresses, phone numbers, full addresses, or free-text form responses. A URL can also contain personal data, so check page locations and query parameters.
Use an internal identifier only when it cannot identify a person by itself and your privacy policy allows it. For a purchase, an order identifier such as T_12345 is useful for deduplication. Do not use an email address as the transaction_id.
gtag('event', 'purchase', {
transaction_id: 'T_12345',
value: 59.98,
currency: 'USD',
items: [
{
item_id: 'SKU_123',
item_name: 'Trail Shoes',
price: 59.98,
quantity: 1
}
]
});Review data sent by the browser, Google Tag Manager variables, and page URLs. A developer can accidentally expose personal data even when the event name looks correct.
Respecting consent
Consent means that a visitor has made a choice about data collection. Connect your consent-management platform to Google’s consent settings before firing analytics and advertising tags. The exact setup depends on your consent-management platform and implementation method.
Your implementation should:
- Load the consent default before analytics tags run.
- Update consent after the visitor makes a choice.
- Avoid sending advertising-related data when ad consent is denied.
- Follow the laws and policies that apply to your visitors and business.
- Document which events can be collected without optional consent.
Consent settings do not make an invalid event valid. You still must avoid personal data and use accurate parameters.
Common data-quality mistakes
| Mistake | Effect | Prevention |
|---|---|---|
| Sending `purchase` on every page load | Duplicate revenue and key events | Fire it once after a confirmed order |
| Reusing a transaction ID | Later orders may be treated as duplicates | Generate one unique ID per order |
| Omitting `currency` or `value` | Revenue and value reports become incomplete | Send the correct currency and numeric value |
| Using text for `value` | Calculations may fail or become inconsistent | Send a number such as `59.98` |
| Firing a lead before successful submission | Inflated lead counts | Fire after the server or form confirms success |
| Sending both `gtag.js` and GTM events | One action may produce two events | Choose one primary implementation |
| Changing event names casually | Historical comparisons become difficult | Use `generate_lead` and `purchase` consistently |
| Testing in production without a plan | Test orders pollute reports | Use a test property or filter test data where appropriate |
A purchase event should represent a completed transaction, not a button click. If payment can fail, trigger the event only after the success response or confirmation page. Keep the transaction ID stable when a user refreshes that page.
A practical review
Before marking an event as a key event, test it in DebugView and Realtime. Confirm the event name, parameters, value, currency, consent behavior, and firing count. Then inspect the next relevant report after processing time has passed.
Exercise
A checkout confirmation page refresh sends the same purchase twice. Which changes should you make?
Show answer
Fire the purchase only after a confirmed order and include a stable, unique transaction_id. Also prevent the implementation from sending the event again when the same confirmation page is refreshed.