{
  "name": "projects/kc-okf-poc-261122/locations/us/changeRequests/345f4080-d80d-4ae6-85ce-a856cda1ae23",
  "uid": "345f4080-d80d-4ae6-85ce-a856cda1ae23",
  "createTime": "2026-11-22T22:36:19.751995724Z",
  "updateTime": "2026-11-22T22:36:20.550489928Z",
  "justification": "Enrichment Agent Proposal: Knowledge Base Entry",
  "labels": {
    "source": "knowledge_agent",
    "generator": "enrichment_agent"
  },
  "author": "kc-studio-enricher@kc-okf-poc-261122.iam.gserviceaccount.com",
  "state": "NEW",
  "resource": "//dataplex.googleapis.com/projects/kc-okf-poc-261122/locations/us/entryGroups/ga4-merch-context",
  "etag": "KREXo6_aKku55r19IlOTYGJQv1P-exy1Ujyvgd7rUR4",
  "changeType": "BATCH_CHANGE_METADATA",
  "batchChangeMetadataRequest": {
    "name": "projects/kc-okf-poc-261122/locations/us/entryGroups/ga4-merch-context",
    "changes": [
      {
        "createEntryRequest": {
          "parent": "projects/kc-okf-poc-261122/locations/us/entryGroups/ga4-merch-context",
          "entryId": "agents",
          "entry": {
            "name": "projects/kc-okf-poc-261122/locations/us/entryGroups/ga4-merch-context/entries/agents",
            "entryType": "projects/dataplex-types/locations/global/entryTypes/document",
            "aspects": {
              "dataplex-types.global.document": {
                "aspectType": "projects/dataplex-types/locations/global/aspectTypes/document",
                "data": {
                  "type": "knowledge-base-root",
                  "job": {
                    "name": "enrichment-agent/enrich-9eb2ed9719624d4e",
                    "runTime": "2026-11-22T22:16:40Z"
                  }
                }
              },
              "dataplex-types.global.overview": {
                "data": {
                  "content": "# GA4 Clickstream Analytics Guide\n\nIndex of the catalog root (2 item(s)).\n\n## What this is\n\nThis knowledge base covers Google Analytics 4 (GA4) clickstream events from the Google Merchandise Store, supporting analysis of user acquisition, session engagement, and e-commerce conversion performance. It documents the `kc-okf-poc-261122.ga4_sample.events` table (Merch Store Clickstream, dataset code `MSC-417`), also available in public BigQuery as `bigquery-public-data.ga4_obfuscated_sample_ecommerce.events_*`. The grain is one row per event, with nested records in `event_params`, `user_properties`, and `items` requiring unnesting. The dataset covers a fixed 92-day period from November 1, 2020, to January 31, 2021 (no new data will arrive), and revenue must be reported in USD using `ecommerce.purchase_revenue_in_usd` and `ecommerce.refund_value_in_usd`.\n\n## Top traps\n\n- **Queries scan entire tables instead of daily slices.** Filter on the table's designated partition column, `event_date_dt` (`DATE`).\n- **Data privacy violation on user identifiers.** `user_pseudo_id` is Tier C2 (pseudonymous) and must never be exported outside the analytics project or joined with CRM or external email lists.\n\n## How to navigate\n\nLook entries up by the ids below. A lookup returns only the entries it names -- a parent never arrives with its children -- so read this page for the id you want, then fetch that id.\n\n- `assets` — 1 table overlays, addressed as `assets/bigquery/\u003cproject\u003e/\u003cdataset\u003e/\u003ctable\u003e`. A dataset entry is its own index -- look the dataset up to see which tables it holds.\n- `documents` — 3 pages of knowledge rather than objects -- operational, one topic each.\n\nBudget about three searches and three lookups per question: search to find the right tier or dataset, then look up the two or three entries it names.\n\n## Contents\n\n| Path | Title | Type | Description |\n|------|-------|------|-------------|\n| catalog/assets | Assets | folder | Index of catalog/assets (1 item(s)). |\n| catalog/documents | Documents | folder | Cross-cutting reference pages for understand what each field means, how to query it correctly, and which business rules apply for analysts and AI agents: Analytics Guidelines and Operations. |",
                  "contentType": "MARKDOWN"
                }
              }
            },
            "entrySource": {
              "labels": {
                "generator": "enrichment_agent",
                "source": "knowledge_agent"
              }
            }
          }
        }
      },
      {
        "createEntryRequest": {
          "parent": "projects/kc-okf-poc-261122/locations/us/entryGroups/ga4-merch-context",
          "entryId": "assets",
          "entry": {
            "name": "projects/kc-okf-poc-261122/locations/us/entryGroups/ga4-merch-context/entries/assets",
            "entryType": "projects/dataplex-types/locations/global/entryTypes/document",
            "aspects": {
              "dataplex-types.global.document": {
                "aspectType": "projects/dataplex-types/locations/global/aspectTypes/document",
                "data": {
                  "type": "knowledge-base-index",
                  "job": {
                    "name": "enrichment-agent/enrich-9eb2ed9719624d4e",
                    "runTime": "2026-11-22T22:16:40Z"
                  }
                }
              },
              "dataplex-types.global.overview": {
                "data": {
                  "content": "# Assets\n\nIndex of catalog/assets (1 item(s)).\n\n## Contents\n\n| Path | Title | Type | Description |\n|------|-------|------|-------------|\n| catalog/assets/bigquery/kc-okf-poc-261122/ga4_sample | Ga4 Sample | folder | Index of catalog/assets/bigquery/kc-okf-poc-261122/ga4_sample (1 item(s)). |",
                  "contentType": "MARKDOWN"
                }
              }
            },
            "parentEntry": "projects/kc-okf-poc-261122/locations/us/entryGroups/ga4-merch-context/entries/agents",
            "entrySource": {
              "labels": {
                "generator": "enrichment_agent",
                "source": "knowledge_agent"
              }
            }
          }
        }
      },
      {
        "createEntryRequest": {
          "parent": "projects/kc-okf-poc-261122/locations/us/entryGroups/ga4-merch-context",
          "entryId": "assets/bigquery/kc-okf-poc-261122/ga4_sample",
          "entry": {
            "name": "projects/kc-okf-poc-261122/locations/us/entryGroups/ga4-merch-context/entries/assets/bigquery/kc-okf-poc-261122/ga4_sample",
            "entryType": "projects/dataplex-types/locations/global/entryTypes/document",
            "aspects": {
              "dataplex-types.global.document": {
                "aspectType": "projects/dataplex-types/locations/global/aspectTypes/document",
                "data": {
                  "type": "knowledge-base-index",
                  "job": {
                    "name": "enrichment-agent/enrich-9eb2ed9719624d4e",
                    "runTime": "2026-11-22T22:16:40Z"
                  }
                }
              },
              "dataplex-types.global.overview": {
                "data": {
                  "content": "# Ga4 Sample\n\nIndex of catalog/assets/bigquery/kc-okf-poc-261122/ga4_sample (1 item(s)).\n\n## Contents\n\n| Path | Title | Type | Description |\n|------|-------|------|-------------|\n| catalog/assets/bigquery/kc-okf-poc-261122/ga4_sample/events | events | file | Context overlay for events. |",
                  "contentType": "MARKDOWN"
                }
              }
            },
            "parentEntry": "projects/kc-okf-poc-261122/locations/us/entryGroups/ga4-merch-context/entries/assets",
            "entrySource": {
              "labels": {
                "generator": "enrichment_agent",
                "source": "knowledge_agent"
              }
            }
          }
        }
      },
      {
        "createEntryRequest": {
          "parent": "projects/kc-okf-poc-261122/locations/us/entryGroups/ga4-merch-context",
          "entryId": "assets/bigquery/kc-okf-poc-261122/ga4_sample/events",
          "entry": {
            "name": "projects/kc-okf-poc-261122/locations/us/entryGroups/ga4-merch-context/entries/assets/bigquery/kc-okf-poc-261122/ga4_sample/events",
            "entryType": "projects/dataplex-types/locations/global/entryTypes/document",
            "aspects": {
              "dataplex-types.global.document": {
                "aspectType": "projects/dataplex-types/locations/global/aspectTypes/document",
                "data": {
                  "type": "table-context",
                  "job": {
                    "name": "enrichment-agent/enrich-9eb2ed9719624d4e",
                    "runTime": "2026-11-22T22:16:40Z"
                  }
                }
              },
              "dataplex-types.global.overview": {
                "data": {
                  "content": "# Events Overview\n\nThe table structure follows the Google Analytics 4 (GA4) event export format, storing user identifiers, nested event parameters, user properties, device specifications, geographic origins, traffic sources, and detailed e-commerce transaction payloads [1].\n\n## Purpose\n\nThe table provides granular event-level clickstream tracking for the merchandise store [1]. It is utilized for digital analytics, funnel analysis, user engagement tracking, and e-commerce conversion reporting [1].\n\n## Columns & Metrics\n\n### Schema Columns\n\n- **event_date** (`STRING`): Date of the event.\n- **event_timestamp** (`INTEGER`)\n- **event_name** (`STRING`): Name of the logged event (e.g., `add_to_cart`, `purchase`).\n- **event_params** (`RECORD`, repeated): Key-value parameters associated with the event, containing nested data types such as string, integer, float, and double values. Key parameters include `ga_session_id`, used in combination with `user_pseudo_id` to establish distinct browsing sessions [1].\n- **event_previous_timestamp** (`INTEGER`)\n- **event_value_in_usd** (`FLOAT`)\n- **event_bundle_sequence_id** (`INTEGER`)\n- **event_server_timestamp_offset** (`INTEGER`)\n- **user_id** (`STRING`)\n- **user_pseudo_id** (`STRING`)\n- **privacy_info** (`RECORD`): User privacy and consent states.\n- **user_properties** (`RECORD`, repeated): Repeated record holding persistent user-level properties and attributes.\n- **user_first_touch_timestamp** (`INTEGER`): Timestamp marking the first time the user interacted with the site.\n- **user_ltv** (`RECORD`): Lifetime value metrics for the user.\n- **device** (`RECORD`): Hardware and browser specifications, including device category, brand, and model details.\n- **geo** (`RECORD`)\n- **app_info** (`RECORD`)\n- **traffic_source** (`RECORD`): Source, medium, and campaign details associated with how the user arrived at the site [1].\n- **stream_id** (`INTEGER`)\n- **platform** (`STRING`)\n- **event_dimensions** (`RECORD`)\n- **ecommerce** (`RECORD`): E-commerce purchase, revenue, and refund attributes, including `purchase_revenue_in_usd` and `refund_value_in_usd` [1].\n- **items** (`RECORD`, repeated): Repeated record containing product and item-level details associated with e-commerce events.\n- **event_date_dt** (`DATE`): Date-typed event date column configured as the table's partition column [1].\n\n### Official Metric Definitions\n\n- **Engaged session**: A browsing session that lasted longer than 10 seconds, recorded 2 or more page views, or contained a purchase event [1]. Sessions are identified by combining `user_pseudo_id` with the `ga_session_id` value extracted from `event_params` [1].\n- **Active buyer (28d)**: A unique `user_pseudo_id` having at least one logged `purchase` event within the trailing 28 days [1].\n- **Net merch revenue**: Calculated as the sum of `ecommerce.purchase_revenue_in_usd` minus the sum of `ecommerce.refund_value_in_usd` [1]. Official metrics must always be reported in USD and must not use local-currency fields [1].\n- **Cart conversion rate**: Total count of sessions containing a `purchase` event divided by the total count of sessions containing an `add_to_cart` event [1].\n\n## Lineage\n\nThe dataset is populated as a copy of the public GA4 sample e-commerce export [1].\n\n## Owner\n\n- **Owning team**: Digital Insights Guild [1]\n- **Dataset reference code**: MSC-417 [1]\n- **Data steward**: Digital Insights Guild on-call steward (contact channel: `#msc-417-data`) [1]\n\n## Governance\n\n- **Sensitivity Classifications**:\n  - `user_pseudo_id`: Classified as **Tier C2 (pseudonymous)**. It must never be exported outside the analytics project and must never be joined with CRM or external email lists [1].\n  - `geo.city` and `geo.metro`: Classified as **Tier C3 (restricted)**. Reporting is permitted only when aggregated to the region or country level; dashboard reporting at the city or metro level is prohibited [1].\n  - `device.*`, `traffic_source.*`, and all other columns: Classified as **Tier C1 (internal)** with standard internal access policies [1].\n- **Retention**: Rows older than 14 months must be purged by the Digital Insights Guild [1].\n- **Refresh & Finality SLA**: The table is loaded once per day; daily data is considered final 72 hours after the calendar day ends [1]. Reporting must not treat data from the most recent 3 days as final numbers [1].\n\n## Data Quality\n\n- **Total Row Count**: The table contains 4,295,584 rows.\n- **Time Horizon**: The dataset covers a fixed historical span of 92 days, running from 2020-11-01 through 2021-01-31 [1]. No newer records will be ingested [1].\n\n## Usage\n\n- **Partition Pruning**: Queries must always filter on the partition column `event_date_dt` to restrict scanned bytes and limit query cost [1].\n- **Marketing Attribution Exclusions**: Any event where `traffic_source.source` is equal to `(data deleted)` must be excluded from marketing attribution analyses [1].\n- **Geographic Aggregations**: Because `geo.city` and `geo.metro` fall under Tier C3 restrictions, dashboard creators and analysts must aggregate geographic metrics up to `geo.region` or `geo.country` [1].\n- **Session Identification**: Because individual events do not carry a top-level session key, analysts must unnest `event_params` to locate `ga_session_id`, concatenating it with `user_pseudo_id` to evaluate session-level engagement and conversion rates [1].\n\n## Table Info\n\n`kc-okf-poc-261122.ga4_sample.events`\n\n## Source References\n1. Merch Store Clickstream: data policy and metric definitions",
                  "contentType": "MARKDOWN"
                }
              }
            },
            "parentEntry": "projects/kc-okf-poc-261122/locations/us/entryGroups/ga4-merch-context/entries/assets/bigquery/kc-okf-poc-261122/ga4_sample",
            "entrySource": {
              "labels": {
                "generator": "enrichment_agent",
                "source": "knowledge_agent"
              }
            }
          }
        }
      },
      {
        "createEntryLinkRequest": {
          "parent": "projects/kc-okf-poc-261122/locations/us/entryGroups/ga4-merch-context",
          "entryLinkId": "link-events-events-776bc352",
          "entryLink": {
            "entryLinkType": "projects/dataplex-types/locations/global/entryLinkTypes/reference",
            "entryReferences": [
              {
                "name": "projects/kc-okf-poc-261122/locations/us/entryGroups/ga4-merch-context/entries/assets/bigquery/kc-okf-poc-261122/ga4_sample/events",
                "type": "SOURCE"
              },
              {
                "name": "projects/kc-okf-poc-261122/locations/us/entryGroups/@bigquery/entries/bigquery.googleapis.com/projects/kc-okf-poc-261122/datasets/ga4_sample/tables/events",
                "type": "TARGET"
              }
            ]
          }
        }
      },
      {
        "createEntryRequest": {
          "parent": "projects/kc-okf-poc-261122/locations/us/entryGroups/ga4-merch-context",
          "entryId": "documents",
          "entry": {
            "name": "projects/kc-okf-poc-261122/locations/us/entryGroups/ga4-merch-context/entries/documents",
            "entryType": "projects/dataplex-types/locations/global/entryTypes/document",
            "aspects": {
              "dataplex-types.global.document": {
                "aspectType": "projects/dataplex-types/locations/global/aspectTypes/document",
                "data": {
                  "type": "knowledge-base-index",
                  "job": {
                    "name": "enrichment-agent/enrich-9eb2ed9719624d4e",
                    "runTime": "2026-11-22T22:16:40Z"
                  }
                }
              },
              "dataplex-types.global.overview": {
                "data": {
                  "content": "# Documents\n\nCross-cutting reference pages for understand what each field means, how to query it correctly, and which business rules apply for analysts and AI agents: Analytics Guidelines and Operations.\n\n## Contents\n\n| Path | Title | Type | Description |\n|------|-------|------|-------------|\n| catalog/documents/computing-standard-ecommerce-metrics | Computing Standard E-Commerce Metrics | file | How do I calculate net revenue, engaged sessions, active buyers, and cart conversion rates across events? |\n| catalog/documents/data-governance-and-quality-boundaries | Data Governance and Quality Boundaries | file | What data is obfuscated, restricted by compliance tiers, or subject to finality lag and retention limits? |\n| catalog/documents/pitfalls | Pitfalls that silently produce wrong answers | file | Why are metric counts inflated, query costs unexpectedly high, or recent numbers unstable? |",
                  "contentType": "MARKDOWN"
                }
              }
            },
            "parentEntry": "projects/kc-okf-poc-261122/locations/us/entryGroups/ga4-merch-context/entries/agents",
            "entrySource": {
              "labels": {
                "generator": "enrichment_agent",
                "source": "knowledge_agent"
              }
            }
          }
        }
      },
      {
        "createEntryRequest": {
          "parent": "projects/kc-okf-poc-261122/locations/us/entryGroups/ga4-merch-context",
          "entryId": "documents/computing-standard-ecommerce-metrics",
          "entry": {
            "name": "projects/kc-okf-poc-261122/locations/us/entryGroups/ga4-merch-context/entries/documents/computing-standard-ecommerce-metrics",
            "entryType": "projects/dataplex-types/locations/global/entryTypes/document",
            "aspects": {
              "dataplex-types.global.document": {
                "aspectType": "projects/dataplex-types/locations/global/aspectTypes/document",
                "data": {
                  "type": "knowledge-base",
                  "job": {
                    "name": "enrichment-agent/enrich-9eb2ed9719624d4e",
                    "runTime": "2026-11-22T22:16:40Z"
                  }
                }
              },
              "dataplex-types.global.overview": {
                "data": {
                  "content": "# Computing Standard E-Commerce Metrics\n\n## Purpose\nThis page provides the operational logic, business rules, and SQL patterns required to calculate core e-commerce key performance indicators—such as net revenue, engaged sessions, active buyers, and cart conversion rate—from Google Analytics 4 (GA4) clickstream events.\n\n## Definitions\n- **Session**: A visit identified by combining `user_pseudo_id` and the nested integer event parameter `ga_session_id`.\n- **Engaged Session**: A session that lasted longer than 10 seconds, recorded 2 or more `page_view` events, or contained a `purchase` event.\n- **Active Buyer (28d)**: A distinct `user_pseudo_id` with at least one `purchase` event within the trailing 28 days.\n- **Net Merch Revenue**: The total of `ecommerce.purchase_revenue_in_usd` minus `ecommerce.refund_value_in_usd`.\n- **Cart Conversion Rate**: The count of distinct sessions containing a `purchase` event divided by the count of distinct sessions containing an `add_to_cart` event.\n\n## How to Query\n- **Partition pruning**: Always filter queries using the partition column `event_date_dt` (or `_TABLE_SUFFIX` on wildcard tables `events_*`) to limit scanned bytes and cost.\n- **Session extraction**: Extract `ga_session_id` from the nested `event_params` array where `key = 'ga_session_id'` and read `value.int_value`.\n- **Currency selection**: Aggregate revenue strictly using `ecommerce.purchase_revenue_in_usd` and `ecommerce.refund_value_in_usd`; never use local-currency fields.\n- **Item-level unnesting**: Flatten the nested `items` array (`CROSS JOIN UNNEST(items) AS items`) when analyzing item-level interactions such as product additions or catalog views.\n- **Attribution filtering**: Exclude rows where `traffic_source.source = '(data deleted)'` from all marketing attribution queries.\n- **Data finalization window**: Do not report on the trailing 3 days as final; data is refreshed daily and finalizes 72 hours after the close of the day.\n- **Privacy and governance constraints**: `user_pseudo_id` is Tier C2 and must not be joined with external CRM/email lists or exported outside the analytics project. Geographic fields `geo.city` and `geo.metro` are Tier C3 and must only be presented aggregated to region or country level.\n\n## Method\n\n### 1. Extracting Sessions and Calculating Cart Conversion Rate\nTo determine session-level conversion, isolate sessions that triggered `add_to_cart` and `purchase`, then divide the converted sessions by the cart-initiating sessions [1], [3].\n\n### 3. Active Buyers (Trailing 28 Days)\nCount distinct pseudonymous users who performed a `purchase` within the 28-day window preceding a target date [1].\n\n## Traps\n- **Underreported numbers due to processing lag.** Generating official metrics for dates within the last 72 hours yields incomplete counts; exclude the trailing 3 days from finalized reporting.\n\n## Source References\n1. Merch Store Clickstream: data policy and metric definitions — defines formulas for engaged sessions, active buyers (28d), net merch revenue, cart conversion rate, reporting exclusions, and sensitivity tiers.\n2. Session Analysis (Unnesting Parameters) — describes extracting `ga_session_id` from the nested `event_params` array.\n3. E-Commerce Product Interest — details flattening the nested `items` array to analyze product-level events.",
                  "contentType": "MARKDOWN"
                }
              }
            },
            "parentEntry": "projects/kc-okf-poc-261122/locations/us/entryGroups/ga4-merch-context/entries/documents",
            "entrySource": {
              "labels": {
                "generator": "enrichment_agent",
                "source": "knowledge_agent"
              }
            }
          }
        }
      },
      {
        "createEntryRequest": {
          "parent": "projects/kc-okf-poc-261122/locations/us/entryGroups/ga4-merch-context",
          "entryId": "documents/data-governance-and-quality-boundaries",
          "entry": {
            "name": "projects/kc-okf-poc-261122/locations/us/entryGroups/ga4-merch-context/entries/documents/data-governance-and-quality-boundaries",
            "entryType": "projects/dataplex-types/locations/global/entryTypes/document",
            "aspects": {
              "dataplex-types.global.document": {
                "aspectType": "projects/dataplex-types/locations/global/aspectTypes/document",
                "data": {
                  "type": "knowledge-base",
                  "job": {
                    "name": "enrichment-agent/enrich-9eb2ed9719624d4e",
                    "runTime": "2026-11-22T22:16:40Z"
                  }
                }
              },
              "dataplex-types.global.overview": {
                "data": {
                  "content": "# Data Governance and Quality Boundaries\n\n## Purpose\nThis page documents the data governance tiers, privacy constraints, obfuscation artifacts, and data finality rules required to query the Merch Store Clickstream dataset (`MSC-417`) correctly [1, 2]. Analysts and automated agents must apply these rules to avoid compliance violations, unfinalized metrics reporting, and distorted revenue or attribution calculations [1].\n\n## Definitions\n- **Tier C1 (Internal)**: Fields including `device.*`, `traffic_source.*`, and all other unclassified columns that carry no additional export or join restrictions [1].\n- **Tier C2 (Pseudonymous)**: Device cookie identifiers (`user_pseudo_id`) restricted strictly to the analytics project; they must never be exported externally or joined with CRM or email identity tables [1, 3].\n- **Tier C3 (Restricted)**: Granular location attributes (`geo.city` and `geo.metro`) that must never be displayed at city level in dashboards and may only be published aggregated to region or country [1].\n- **Finality Lag**: The 72-hour window following day-end during which daily partition data is refreshed and considered provisional [1].\n\n## How to Query\n- **Apply Date Partition Filters**: Every query against `kc-okf-poc-261122.ga4_sample.events` or wildcard tables (`events_*`) must include a filter on the partition column `event_date_dt` (or `_TABLE_SUFFIX`) to prevent full table scans and control compute costs [1, 4, 5].\n- **Enforce Date Coverage Limits**: The dataset spans exactly 92 daily tables from `2020-11-01` to `2021-01-31`; no newer records will arrive, and queries outside this interval return no data [1, 2].\n- **Observe Finality Windows**: Because data refreshes once per day and requires 72 hours to achieve finality, queries reporting final metrics must exclude the trailing 3 days [1].\n- **Filter Deleted Attribution Sources**: Exclude records where `traffic_source.source = '(data deleted)'` across all marketing attribution reports [1].\n- **Enforce Currency Normalization**: Calculate net merchandise revenue exclusively using USD columns as `SUM(ecommerce.purchase_revenue_in_usd) - SUM(ecommerce.refund_value_in_usd)`, never aggregating local currency fields [1].\n- **Aggregate Tier C3 Geographies**: When reporting geography, aggregate `geo.city` and `geo.metro` up to `geo.region` or `geo.country` before exposing results in dashboards [1].\n- **Unnest Nested Structures**: Extract attributes from nested arrays and structs (`event_params`, `user_properties`, `items`) via `UNNEST()` rather than attempting direct column references [6, 7, 8].\n\n```sql\nSELECT\n  PARSE_DATE('%Y%m%d', event_date) AS event_date,\n  geo.country AS country,\n  geo.region AS region,\n  COUNT(DISTINCT user_pseudo_id) AS active_users,\n  COUNTIF(event_name = 'purchase') AS total_purchases,\n  SUM(ecommerce.purchase_revenue_in_usd) - SUM(IFNULL(ecommerce.refund_value_in_usd, 0)) AS net_merch_revenue_usd\nFROM\n  `kc-okf-poc-261122.ga4_sample.events`\nWHERE\n  event_date_dt BETWEEN '2020-11-01' AND '2021-01-31'\n  AND traffic_source.source != '(data deleted)'\nGROUP BY\n  1, 2, 3;\n```\n\n\n## Method\nTo calculate standard business metrics within governance boundaries, proceed in the following order:\n\n1. **Partition and Finality Boundary**: Restrict the scan using `event_date_dt` between `2020-11-01` and `2021-01-31`, ensuring that if running on live pipelines, the most recent 72 hours (3 days) are omitted from finalized outputs [1, 2].\n2. **Attribution Cleansing**: Apply a `WHERE` predicate filtering out `traffic_source.source = '(data deleted)'` for any acquisition or campaign attribution reporting [1].\n3. **Session Identification**: Identify distinct sessions using `user_pseudo_id` combined with the unnested `event_params` integer value where `key = 'ga_session_id'` [1, 7].\n4. **Metric Computation**:\n   - **Engaged Sessions**: Count sessions identified by `user_pseudo_id` and `ga_session_id` that had a duration greater than 10 seconds, accumulated 2 or more `page_view` events, or logged a `purchase` event [1, 4].\n   - **Active Buyers (28d)**: Identify unique `user_pseudo_id` counts that contain at least one `purchase` event within the trailing 28-day window [1, 4].\n   - **Cart Conversion Rate**: Calculate total sessions containing at least one `purchase` event divided by total sessions containing at least one `add_to_cart` event [1, 4, 8].\n   - **Net Merch Revenue**: Compute `SUM(ecommerce.purchase_revenue_in_usd) - SUM(ecommerce.refund_value_in_usd)` [1].\n5. **Privacy and Compliance Export Gate**: Ensure `user_pseudo_id` is not joined with external CRM/email lists or exported outside the analytics project, and verify geographic breakdowns are rolled up to `geo.region` or `geo.country` [1].\n\n## Traps\n- **Reported numbers change retroactively on recent dates.** You queried data inside the 72-hour finality lag window; data is refreshed daily and is only final 3 days after day-end [1].\n- **Marketing attribution reports show distorted acquisition channels.** You did not remove suppressed sources; filter out events where `traffic_source.source = '(data deleted)'` [1].\n- **Dashboard violates spatial compliance policies.** You displayed `geo.city` or `geo.metro` directly; these columns are Tier C3 restricted and must be rolled up to `geo.region` or `geo.country` [1].\n- **Queries breach customer data protection rules.** You exported `user_pseudo_id` outside the analytics project or joined it with email/CRM tables; `user_pseudo_id` is Tier C2 pseudonymous and prohibited from external linkage [1].\n- **Revenue totals are distorted by exchange rates.** You summed raw local currency fields; net revenue must be calculated strictly as `SUM(ecommerce.purchase_revenue_in_usd) - SUM(ecommerce.refund_value_in_usd)` [1].\n- **Queries scan massive byte volumes and incur high query costs.** You omitted the partition predicate; always filter queries on `event_date_dt` or `_TABLE_SUFFIX` [1, 4, 5].\n- **Session counts are inflated or inaccurate.** You counted rows directly instead of unnesting `event_params` for `key = 'ga_session_id'` and pairing with `user_pseudo_id`, or you failed to isolate the `session_start` event [1, 7].\n- **Metrics cannot be reconciled against live GA4 demo accounts.** The sample dataset contains obfuscated placeholders (`\u003cOther\u003e`, `NULL`, `''`) introduced specifically to protect business privacy, limiting direct consistency with production GA4 accounts [2].\n- **No data is returned for queries beyond January 2021.** The dataset covers a fixed historical window of 92 days from November 1, 2020, to January 31, 2021; no newer partitions exist [1, 2].\n\n## Source References\n1. Merch Store Clickstream: data policy and metric definitions — states the data tiers, finality lag, retention limits, and core business metric definitions for dataset `MSC-417`.\n2. Google Analytics 4 BigQuery Public Dataset — states that public dataset records are obfuscated with placeholders and cover a fixed 92-day period from November 1, 2020, to January 31, 2021.\n3. High-Level Event and User Volume — states that total unique users are derived from device cookies via `COUNT(DISTINCT user_pseudo_id)`.\n4. Using Analytics Events — states how to query core events (`page_view`, `session_start`, `purchase`) across date ranges using wildcard table suffixes.\n5. Querying a Specific Date Range — states that queries must filter on daily partition columns like `event_date_dt` to limit data scanned and optimize query cost.\n6. Using Google Analytics 4 BigQuery Public Dataset — states that GA4 exports use nested arrays and structs that require `UNNEST()` to flatten for querying.\n7. Session Analysis (Unnesting Parameters) — states that sessions require unnesting `ga_session_id` from `event_params` on `session_start` events.\n8. E-Commerce Product Interest — states that item-level interactions like `add_to_cart` require unnesting the `items` array.\n\nSee also: `assets/bigquery/kc-okf-poc-261122/ga4_sample/events` — the table entry for `kc-okf-poc-261122.ga4_sample.events`.",
                  "contentType": "MARKDOWN"
                }
              }
            },
            "parentEntry": "projects/kc-okf-poc-261122/locations/us/entryGroups/ga4-merch-context/entries/documents",
            "entrySource": {
              "labels": {
                "generator": "enrichment_agent",
                "source": "knowledge_agent"
              }
            }
          }
        }
      },
      {
        "createEntryRequest": {
          "parent": "projects/kc-okf-poc-261122/locations/us/entryGroups/ga4-merch-context",
          "entryId": "documents/pitfalls",
          "entry": {
            "name": "projects/kc-okf-poc-261122/locations/us/entryGroups/ga4-merch-context/entries/documents/pitfalls",
            "entryType": "projects/dataplex-types/locations/global/entryTypes/document",
            "aspects": {
              "dataplex-types.global.document": {
                "aspectType": "projects/dataplex-types/locations/global/aspectTypes/document",
                "data": {
                  "type": "knowledge-base",
                  "job": {
                    "name": "enrichment-agent/enrich-9eb2ed9719624d4e",
                    "runTime": "2026-11-22T22:16:40Z"
                  }
                }
              },
              "dataplex-types.global.overview": {
                "data": {
                  "content": "# Pitfalls that Silently Produce Wrong Answers\n\n## Purpose\nThis page addresses why metric totals become inflated, query scan costs spike, or recent figures shift across query runs in GA4 clickstream event data. It provides the operational filters, unnesting logic, and business rules required to avoid silent calculation errors.\n\n## How to Query\n- **Filter daily partitions**: Always constrain the partition column `event_date_dt` (or `_TABLE_SUFFIX` when querying wildcard tables such as `events_*`) in the `WHERE` clause to avoid full-table scans across all 92 daily tables [1, 2, 6].\n- **Exclude deleted attribution sources**: Filter out events where `traffic_source.source = '(data deleted)'` when calculating any marketing attribution metric [1].\n- **Use USD revenue fields**: Calculate net merchandise revenue as `SUM(ecommerce.purchase_revenue_in_usd) - SUM(ecommerce.refund_value_in_usd)`; never query or sum local-currency revenue columns [1].\n- **Unnest repeated records**: Flatten nested arrays such as `event_params`, `items`, and `user_properties` using `LEFT JOIN UNNEST(...)` or `CROSS JOIN UNNEST(...)` prior to referencing nested keys and attributes [5, 7].\n- **Adhere to privacy tiers**: Do not export `user_pseudo_id` outside the analytics project or join it with external CRM/email lists (Tier C2); never display `geo.city` or `geo.metro` at city level in dashboards—aggregate them to region or country (Tier C3) [1].\n\n```sql\n-- Pattern: Pruning partitions, extracting session ID, and excluding deleted traffic\nSELECT\n  event_date_dt,\n  COUNT(DISTINCT user_pseudo_id) AS active_users,\n  COUNT(DISTINCT ep.value.int_value) AS total_sessions\nFROM `kc-okf-poc-261122.ga4_sample.events`\nLEFT JOIN UNNEST(event_params) AS ep\n  ON ep.key = 'ga_session_id'\nWHERE event_date_dt BETWEEN '2020-11-01' AND '2020-11-30'\n  AND event_name = 'session_start'\n  AND traffic_source.source != '(data deleted)'\nGROUP BY event_date_dt;\n```\n\n## Traps\n- **Query scan costs and runtimes are unexpectedly high.** You queried wildcard or partitioned event tables without partition pruning; filter directly on `event_date_dt` (or `_TABLE_SUFFIX` on `events_*`) to limit scanned partitions to the needed window [1, 2, 6].\n- **Session counts equal event counts or are inflated.** You counted rows or distinct `ga_session_id` values across all events; sessions are not single rows, so you must isolate `event_name = 'session_start'` and unnest `event_params` to count distinct `value.int_value` where `key = 'ga_session_id'`, or uniquely identify sessions across broader event streams using `user_pseudo_id` combined with `ga_session_id` [1, 3].\n- **Numbers for the most recent 3 days change or drop unexpectedly.** You reported unfinalized records; data refreshes daily but is finalized only 72 hours after the calendar day closes, meaning the trailing 3 days must not be published as final numbers [1].\n- **Queries return zero rows for dates outside late 2020 and early 2021.** You queried dates outside the fixed dataset boundary; the sample table spans exactly November 1, 2020, to January 31, 2021 (92 daily tables), and no newer dates exist [1, 4].\n- **Marketing campaign attribution totals do not tie to verified source figures.** You included redacted rows; marketing reports must explicitly exclude records where `traffic_source.source` equals `'(data deleted)'` [1].\n- **Multicurrency revenue reports produce incorrect totals.** You aggregated local transaction values; calculate revenue exclusively using `ecommerce.purchase_revenue_in_usd` and subtract `ecommerce.refund_value_in_usd` [1].\n- **Item-level metrics (such as add-to-cart or product views) fail to resolve.** You referenced `items.item_name` directly without flattening; e-commerce product interactions reside in the repeated `items` array and require `UNNEST(items)` to access item-level columns [5, 7].\n- **Metrics do not match live Google Merchandise Store demo data.** You assumed the public export mirrors live property telemetry; public dataset values are deliberately obfuscated with placeholders such as `\u003cOther\u003e`, `NULL`, and empty strings `''` for privacy protection [4].\n- **Compliance audit flags privacy policy violations.** You joined `user_pseudo_id` to external CRM records or displayed raw city dimensions; `user_pseudo_id` is restricted pseudonymous data (Tier C2), and geographic data in `geo.city` and `geo.metro` (Tier C3) may only be reported aggregated to the region or country level [1].\n\n## Source References\n1. Merch Store Clickstream: data policy and metric definitions — states the 72-hour finalization delay, partition filtering mandate on `event_date_dt`, attribution exclusion rule for `(data deleted)`, USD revenue formula, and C2/C3 data classification restrictions.\n2. Querying a Specific Date Range — states that partitioning queries on `event_date_dt` reduces bytes scanned and demonstrates active user count query structure.\n3. Session Analysis (Unnesting Parameters) — states that sessions are not independent rows and details unnesting `ga_session_id` from `event_params` on `session_start`.\n4. Google Analytics 4 BigQuery Public Dataset — states that data covers 92 daily tables from November 1, 2020, to January 31, 2021, and contains obfuscation placeholders like `\u003cOther\u003e`.\n5. E-Commerce Product Interest — states that item interactions are stored in the nested `items` array and require `UNNEST(items)` to access fields such as `item_name`.\n6. Using Analytics Events — states that date-bound queries on wildcard tables like `events_*` require filtering with `_TABLE_SUFFIX`.\n7. Using Google Analytics 4 BigQuery Public Dataset — states that GA4 data contains nested record structures and arrays that require BigQuery's `UNNEST()` function to process.\n\nSee also: `assets/bigquery/kc-okf-poc-261122/ga4_sample/events` — the table entry for `kc-okf-poc-261122.ga4_sample.events`.",
                  "contentType": "MARKDOWN"
                }
              }
            },
            "parentEntry": "projects/kc-okf-poc-261122/locations/us/entryGroups/ga4-merch-context/entries/documents",
            "entrySource": {
              "labels": {
                "generator": "enrichment_agent",
                "source": "knowledge_agent"
              }
            }
          }
        }
      }
    ],
    "description": {
      "job": {
        "name": "projects/kc-okf-poc-261122/locations/us/enrichmentTasks/7228fab9-2fe6-40fa-a1d6-bae8740aa709/runs/d3704062-699a-4661-9299-1d42e5d4266d"
      }
    }
  }
}
