The Semantic Layer Reference GA4 Data Needs for AI Readiness
Organizations are increasingly asking a pivotal question about whether we can help develop semantic layers on top of BigQuery.
The drive behind this request is clear. Companies possess vast amounts of data in Google Analytics 4 (GA4) and want to leverage AI agents to mine that data for insights. However, they are discovering a hard truth that AI readiness is about the model you choose and the context you provide.
Without a translation layer, an AI agent interacting with raw analytics data is likely to misinterpret the data, generate incorrect queries, or return unreliable answers. To bridge the gap between technical data collection and business intelligence, organizations must move beyond the traditional Solution Design Reference (SDR). This document is typically used by analytics teams to define how data is collected and structured, often as a static spreadsheet that lacks the business context needed for broader interpretation.
While the SDR serves as a crucial blueprint for developers and analysts to implement tracking tags, it’s often a static spreadsheet that lacks business context. To support AI transformation, organizations need to embrace a new standard known as the Semantic Layer Reference (SLR).
The “Lost-in-Translation” Problem
To understand why a semantic layer is necessary, it helps to compare how an AI agent interprets raw data with the reality of the GA4 export schema in BigQuery.
Imagine a media company wants an AI agent to answer a simple question, “What was the most popular video category viewed yesterday?”
The team has implemented a custom event called video_complete and a custom dimension called video_category. Without a semantic layer, the AI assumes a standard, flat database structure. It generates a “naive” SQL query looking for a column named video_category.
The result is an error. In raw GA4 BigQuery exports, custom dimensions do not exist as their own columns.
The AI sees a confusing, nested structure. The data for the “video category” is buried inside a repeated record field called event_params. To answer the question, the AI must write a complex SQL that “unnests” the data. It requires specific logic to select a value from event_params, filter by the key video_category, and extract the string value.
Without a semantic layer defining these relationships, the AI tool rarely generates this correctly. It struggles with unnesting logic and often guesses the wrong data type, looking for an ID in an integer field when it is actually a string.
This confusion extends to custom event naming. If a user asks, “How many users completed a level?”, the AI might look for a standard event like level_up. If your data uses lvl_comp, the AI returns zero results. Furthermore, the AI might calculate “users” by counting distinct user IDs, which returns zero for anonymous traffic in GA4. It lacks the context to know that it should count user_pseudo_id.
The Role of the Semantic Layer
As Jovani Rosado, Lead Data Engineer on our Data & AI team, defines it, a semantic layer is a “detailed, defined, and descriptive set of digital assets over any complex data.” It serves as a “single source of truth” by applying business logic, relationships, and constraints to the raw data.
Typically, data transformation pipelines start with tools like dbt Core or Google Cloud Dataform, which help teams define, version, and manage transformation logic in a repeatable way. Those tools can support the creation of clean, aggregated “gold” layer tables, and the metadata needed to make a semantic layer usable. The semantic layer’s primary functions are essential for AI accuracy:
Translating technical jargon
It maps cryptic column names to clear business terms.
Providing Context via Metadata
It pushes descriptions and constraints (primary keys, foreign keys) directly into the database schema (e.g., BigQuery), allowing AI tools like Gemini to understand how tables relate.
Centralize business logic
It contains validated calculations for metrics like “Sessions” or “Conversion Rate,” ensuring the AI does not have to guess the formula.
While an SDR documents how data is collected, an SLR documents how that data is interpreted for business use. It is the dictionary that the AI uses to understand the language of your data.
Rethinking Documentation for AI Readiness
Traditionally, SDRs are maintained in spreadsheets with complex cell formatting. While useful for humans, these can be difficult for Large Language Models (LLMs) to interpret.
To prepare for an AI-driven future, analytics teams are beginning to make a shift toward Data Layer Guides, which are text-based, markdown documentation that is easily readable by LLMs.
This shift enables a powerful, automated workflow:
- Ingest
An AI agent reads the text-based Data Layer Guide. - Generate
The AI generates the thousands of lines of YAML code required for dbt to define the semantic layer. - Deploy
This code is deployed to the data warehouse, automatically populating table descriptions and column definitions.
By moving to AI-friendly documentation formats, teams can automate the heavy lifting required to build the semantic layer itself.
The Goal for Self-Service Natural Language Queries
The ultimate goal of this architecture is to enable self-service analytics through Text-to-SQL or Natural Language Query (NLQ). This aligns with the rise of conversational analytics, where tools like Google’s Conversational Analytics API allow developers to build data agents that chat directly with structured data.
Consider a scenario where a non-technical user opens a tool like BigQuery Data Canvas and types, “Show me the distinct transaction IDs from yesterday.”
If the semantic layer is correctly implemented, the AI (e.g., Gemini) scans the metadata that has been populated. It sees the descriptions, identifies the correct ecommerce data mart, understands the primary keys, and generates the correct SQL query without the user ever needing to know what “unnesting” means.
Preparing Your GA4 and GTM Setup
While heavy lifting happens in the data warehouse, preparation begins in Google Tag Manager (GTM) and GA4. Steps taken here can significantly streamline the development of your SLR.
Audit and Clean Up GA4 Implementation
Before teams can standardize, they need to clean up the data being collected. Conduct an audit to identify and remove redundant events or inconsistent parameters that add noise to your analytics.
Enforce Strict Naming Conventions
Establish a consistent naming convention for all custom events and parameters, such as object_verb (e.g., form_submit, video_play). Always use lowercase and snake_case.
Develop a Standardized Tagging Plan (SDR)
Your Solution Design Reference isn’t obsolete. It is the foundation, so ensure your SDR is updated to reflect these AI-ready standards, serving as the clean blueprint your semantic layer will reference.
Centralize Control with a Data Layer
Avoid hardcoding tracking snippets. Implement a comprehensive data layer that pushes event and user information to GTM. This decouples tracking from website code, making it easier to manage naming conventions without constant developer intervention.
Send Meaningful User Properties
Enrich the data stream by sending specific user properties, such as user_type (e.g., guest, member, premium). This data is essential for building user segments in your semantic layer.
Train Your Team on AI Literacy
AI requires a new way of thinking. Train your analytics team not just on the tools, but on “prompt engineering” and how to ask the right questions to extract accurate insights from your new semantic layer.
The Business Value of Context
Investing in a semantic layer before building an AI tool directly impacts return on investment.
This alignment is consistent with broader industry trends. The resurgence of semantic layers is being driven specifically by “Agentic AI.” AI models need data and the business context that only a semantic layer can provide to avoid confident but incorrect answers.
At the same time, teams should avoid the mistake of trying to map every field in the database. In our experience, the most effective semantic layers are scoped around the actual questions business users ask, rather than attempting to replicate the entire physical schema.
Building an AI tool on raw, messy data is expensive. Data scientists often spend the majority of their time cleaning inconsistent data. A semantic layer pre-processes this information, allowing the AI development team to focus on the model itself, helping increase speed to market.
By embedding clear business definitions into the data, a semantic layer reduces the risks of ‘hallucinations’ and helps ensure the AI’s answers are accurate and trustworthy.
Moving From Collection to Intelligence
The shift from simple data collection to AI-driven intelligence requires an infrastructure overhaul. The raw export from GA4 is powerful, but it is not ready for direct interrogation by an AI agent. By developing and implementing a robust Semantic Layer Reference, organizations can ensure their data is accurate, accessible, and ready to drive business value.
News & Insights
Related Perspectives