<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Yasmine Makia</title>
    <description>The latest articles on DEV Community by Yasmine Makia (@yasmakia).</description>
    <link>https://dev.to/yasmakia</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4278622%2Fef78630b-a96d-43ad-b483-28cdb85183fb.png</url>
      <title>DEV Community: Yasmine Makia</title>
      <link>https://dev.to/yasmakia</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/yasmakia"/>
    <language>en</language>
    <item>
      <title>I built a RAG assistant that answers GA4 and GTM tracking questions</title>
      <dc:creator>Yasmine Makia</dc:creator>
      <pubDate>Wed, 02 Dec 2026 13:34:49 +0000</pubDate>
      <link>https://dev.to/yasmakia/i-built-a-rag-assistant-that-answers-ga4-and-gtm-tracking-questions-3pkm</link>
      <guid>https://dev.to/yasmakia/i-built-a-rag-assistant-that-answers-ga4-and-gtm-tracking-questions-3pkm</guid>
      <description>&lt;p&gt;If you work with Google Analytics 4 and Google Tag Manager, you probably ask yourself the same questions again and again.&lt;/p&gt;

&lt;p&gt;Why don't my event parameters show up in reports? Why do I see "(not set)"? Why is my page view counted twice? How do I set up Consent Mode v2?&lt;/p&gt;

&lt;p&gt;The answers exist, but they are spread across documentation pages, forum threads and old notes. So I built a small assistant that answers these tracking questions and always shows where the answer comes from.&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;Live demo:&lt;/strong&gt; &lt;a href="https://rag-ga4-tracking-assistant.streamlit.app" rel="noopener noreferrer"&gt;rag-ga4-tracking-assistant.streamlit.app&lt;/a&gt;&lt;br&gt;
👉 &lt;strong&gt;Code:&lt;/strong&gt; &lt;a href="https://github.com/yasmakia/rag-ga4-tracking-assistant" rel="noopener noreferrer"&gt;github.com/yasmakia/rag-ga4-tracking-assistant&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is RAG, in plain words?
&lt;/h2&gt;

&lt;p&gt;RAG means Retrieval-Augmented Generation. Instead of asking a language model to answer from memory, you do two things:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Retrieve&lt;/strong&gt;: find the most relevant passages in your own documents.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Generate&lt;/strong&gt;: ask the model to answer using only those passages.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For tracking questions, this matters. A model answering from memory can sound confident and still be wrong about a GA4 setting. With RAG, the answer is tied to a source you can check.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the assistant does
&lt;/h2&gt;

&lt;p&gt;You type a question like:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Why don't my event parameters appear in GA4 reports?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The assistant:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Searches a knowledge base of GA4 and GTM notes.&lt;/li&gt;
&lt;li&gt;Picks the 4 most relevant passages.&lt;/li&gt;
&lt;li&gt;Writes a short answer based only on those passages.&lt;/li&gt;
&lt;li&gt;Adds citations like [1] and [2], so you can see exactly which note was used.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The knowledge base covers the GA4 event model, custom dimensions, key events and ecommerce, the GTM data layer, tags, triggers and variables, Consent Mode v2, and common troubleshooting cases (DebugView, duplicate page views, "(not set)", self-referrals).&lt;/p&gt;

&lt;h2&gt;
  
  
  How it works
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Markdown notes ──► split by section ──► embeddings
                                            │
                                            ▼
Question ──► embedding ──► ChromaDB search (top 4)
                                            │
                                            ▼
                        Claude + grounded prompt ──► answer with [n] citations
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The stack is simple on purpose:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Part&lt;/th&gt;
&lt;th&gt;Choice&lt;/th&gt;
&lt;th&gt;Why&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Knowledge base&lt;/td&gt;
&lt;td&gt;Markdown files&lt;/td&gt;
&lt;td&gt;Easy to write, review and version in Git&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Embeddings&lt;/td&gt;
&lt;td&gt;all-MiniLM-L6-v2&lt;/td&gt;
&lt;td&gt;Runs locally and costs nothing&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Vector database&lt;/td&gt;
&lt;td&gt;ChromaDB&lt;/td&gt;
&lt;td&gt;Persistent, cosine similarity, no server to manage&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Language model&lt;/td&gt;
&lt;td&gt;Claude (Anthropic API)&lt;/td&gt;
&lt;td&gt;Good at following "answer only from these sources"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Interface&lt;/td&gt;
&lt;td&gt;Streamlit&lt;/td&gt;
&lt;td&gt;A working web demo in a few lines of Python&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Each note is split by section, not by a fixed number of characters. A section in my notes usually covers one topic ("Custom dimensions", "Duplicate page views"), so the search returns a complete idea instead of half a paragraph.&lt;/p&gt;

&lt;h2&gt;
  
  
  Testing it: 20 real tracking questions
&lt;/h2&gt;

&lt;p&gt;A demo that "looks good" is not enough. I wanted numbers.&lt;/p&gt;

&lt;p&gt;I wrote 20 real-world tracking questions. For each one, I noted which file in the knowledge base should be found, and which keywords the answer should contain. Then I measured how often the search finds the right source.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Metric&lt;/th&gt;
&lt;th&gt;Result&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Hit@1 (right source ranked first)&lt;/td&gt;
&lt;td&gt;95% (19/20)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Hit@4 (right source in the top 4)&lt;/td&gt;
&lt;td&gt;100% (20/20)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;MRR (mean reciprocal rank)&lt;/td&gt;
&lt;td&gt;0.97&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;These retrieval metrics run automatically with GitHub Actions on every push. If I change the notes or the chunking and the search gets worse, I see it right away.&lt;/p&gt;

&lt;h3&gt;
  
  
  The one question it missed
&lt;/h3&gt;

&lt;p&gt;Only one question did not get the right source in first position:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Why should I push ecommerce null to the data layer?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The right note came second. The reason is simple: this topic appears in two places in my notes, in the ecommerce file and in the data layer file. The search found both, just not in the order I expected. The final answer was still correct because both passages were sent to the model.&lt;/p&gt;

&lt;p&gt;This is a useful lesson: when the same topic lives in several documents, retrieval gets ambiguous. Cleaner notes often help more than a fancier model.&lt;/p&gt;

&lt;h2&gt;
  
  
  Keeping a public demo affordable
&lt;/h2&gt;

&lt;p&gt;A public demo that calls a paid API can get expensive fast. So I added limits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;10 questions per visitor session&lt;/li&gt;
&lt;li&gt;200 questions per day in total&lt;/li&gt;
&lt;li&gt;Answers capped at 600 tokens&lt;/li&gt;
&lt;li&gt;A monthly spending limit set in the Anthropic console&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And the API key is stored in Streamlit secrets, never in the code.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I would improve next
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Hybrid search&lt;/strong&gt;: combine keyword search (BM25) with embeddings, so exact terms like "page_view" or "gtm.js" are matched better.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Re-ranking&lt;/strong&gt;: reorder the top results before sending them to the model.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A French knowledge base&lt;/strong&gt;, for French-speaking marketing and analytics teams.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Automatic answer grading&lt;/strong&gt; with a second model, on top of the keyword check.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;RAG is a good fit for tracking questions&lt;/strong&gt;, because the answer must be correct and checkable.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Measure retrieval, not just answers.&lt;/strong&gt; If the right source is not found, the model cannot fix it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Your notes matter as much as your model.&lt;/strong&gt; Clear, well-split documents gave me most of the quality.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can try the &lt;a href="https://rag-ga4-tracking-assistant.streamlit.app" rel="noopener noreferrer"&gt;live demo&lt;/a&gt; or read the &lt;a href="https://github.com/yasmakia/rag-ga4-tracking-assistant" rel="noopener noreferrer"&gt;code on GitHub&lt;/a&gt;. If you work on GA4 or GTM tracking, I'd love to know which questions you would add to the test set.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;I'm Yasmine Makia, an analytics engineer working on GA4/GTM tracking, data and AI. More on &lt;a href="https://yasminemakia.com" rel="noopener noreferrer"&gt;yasminemakia.com&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ga4</category>
      <category>rag</category>
      <category>python</category>
      <category>analytics</category>
    </item>
  </channel>
</rss>
