<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Alberto Mendez on Medium]]></title>
        <description><![CDATA[Stories by Alberto Mendez on Medium]]></description>
        <link>https://medium.com/@alberto.mendez_37026?source=rss-97bc22dbece0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*-RbyoCSIPSxu7Gxs</url>
            <title>Stories by Alberto Mendez on Medium</title>
            <link>https://medium.com/@alberto.mendez_37026?source=rss-97bc22dbece0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 01:49:45 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@alberto.mendez_37026/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Track HubSpot Breeze AI forms submissions with Google Tag Manager]]></title>
            <link>https://medium.com/agorapulse-stories/track-hubspot-breeze-ai-forms-submissions-with-google-tag-manager-9f843a1ca200?source=rss-97bc22dbece0------2</link>
            <guid isPermaLink="false">https://medium.com/p/9f843a1ca200</guid>
            <category><![CDATA[breeze]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[hubspot]]></category>
            <category><![CDATA[google-tag-manager]]></category>
            <category><![CDATA[tracking]]></category>
            <dc:creator><![CDATA[Alberto Mendez]]></dc:creator>
            <pubDate>Wed, 25 Jun 2025 07:26:27 GMT</pubDate>
            <atom:updated>2025-06-25T08:24:52.303Z</atom:updated>
            <content:encoded><![CDATA[<h3>Tracking Breeze AI Forms in HubSpot: A Step-by-Step Guide</h3><p>HubSpot recently introduced a new form type through its Breeze AI add-on, designed to boost conversion rates. At Agorapulse, after switching to these forms, we saw a 20% increase in page conversions.</p><p>What makes these forms so effective? When a prospect enters their email, Breeze AI automatically pre-fills key details like company name, size, and industry which minimizing the number of fields the user has to complete. This reduced friction leads to significantly higher conversion rates.</p><p>However, tracking submissions from these forms presents a challenge. Breeze AI forms use nested iframes, with the submit button inside an inner frame, which prevents traditional form submission tracking or other HubSpot forms submission listeners. While HubSpot provides documentation for iframe-based forms, it doesn’t apply to Breeze AI, as it uses a different architecture.</p><p>As a temporary solution, we configured thank-you pages with unique URLs to detect successful submissions. But in certain cases, we needed more detailed form content at the submission stage.</p><p>At Agorapulse, we tackled this problem head-on, so you don’t have to. Here’s a step-by-step guide to help you reliably track submissions from Breeze AI forms.</p><h3>1-In Google Tag Manager, create a custom HTML tag that triggers on all pages. You can copy-paste this code:</h3><pre>&lt;script type=&quot;text/javascript&quot;&gt;<br>function pushHubSpotFormToDataLayer(formGuid, eventDetail, submittedFields) { // Function to push form submission details to the dataLayer, designed to be called with the fully prepared submittedFields.<br>  window.dataLayer = window.dataLayer || [];<br><br>  window.dataLayer.push({<br>    &#39;event&#39;: &#39;hubspotFormSubmit&#39;, // Your GTM Custom Event name<br>    &#39;formGuid&#39;: formGuid,<br>    &#39;hubspotEventDetails&#39;: eventDetail, // Keep raw event.detail for debugging/extra info<br>    &#39;submittedFields&#39;: submittedFields // Object of fieldName: fieldValue<br>  });<br>}<br><br>window.addEventListener(&#39;hs-form-event:on-submission:success&#39;, function(event) { // Listen for the custom HubSpot form submission success event, cannot be &#39;async&#39; due to ES5 restriction.<br>  var formGuid = event.detail.formId; // Get the form ID from the event detail<br>  var submittedFields = {}; // Initialize an object to store field data<br><br><br>  if (event.detail &amp;&amp; event.detail.data &amp;&amp; Array.isArray(event.detail.data)) { // --- Option 1: Try to get data directly from event.detail.data, if the event itself contains the submitted data (most efficient).<br>    event.detail.data.forEach(function(field) {<br>      if (field.name &amp;&amp; field.value !== undefined) {<br>        submittedFields[field.name] = field.value;<br>      }<br>    });<br><br>    pushHubSpotFormToDataLayer(formGuid, event.detail, submittedFields); // If data is found directly, push to dataLayer immediately.<br><br>  } else {<br>    console.warn(&#39;event.detail.data not found. Attempting to fetch form field values via HubSpotFormsV4 API.&#39;); // --- Option 2: Fallback to HubSpotFormsV4.getFormFieldValues(), if data is not in event.detail.data, attempt to fetch it using the HubSpot Forms API., this part is asynchronous and uses .then() callbacks instead of await.<br>        try { // Add a try-catch block for synchronous errors (e.g., if HubSpotFormsV4 is not defined at all)<br>      if (typeof HubSpotFormsV4 !== &#39;undefined&#39; &amp;&amp; typeof HubSpotFormsV4.getFormFromEvent === &#39;function&#39;) {<br>        HubSpotFormsV4.getFormFromEvent(event)<br>          .getFormFieldValues()<br>          .then(function(formValues) { // Use .then() for asynchronous result<br>            if (formValues &amp;&amp; Array.isArray(formValues)) {<br>              formValues.forEach(function(field) {<br>                if (field.name &amp;&amp; field.value !== undefined) {<br>                  submittedFields[field.name] = field.value;<br>                }<br>              });<br>            }<br>            pushHubSpotFormToDataLayer(formGuid, event.detail, submittedFields); // Push to dataLayer AFTER values are retrieved asynchronously.<br>          })<br>          .catch(function(error) { // Handle errors from the Promise<br>            console.error(&#39;❌ Error fetching form field values using HubSpotFormsV4 API:&#39;, error);<br>            pushHubSpotFormToDataLayer(formGuid, event.detail, {}); // .Push with empty fields // Even if an error occurs, try to push what we have to the dataLayer<br>          });<br>      } else {<br>        console.error(&#39;❌ HubSpotFormsV4 or getFormFromEvent is not defined. Cannot fetch form values as a fallback.&#39;);<br><br>        pushHubSpotFormToDataLayer(formGuid, event.detail, {}); // If API is not defined, push what we have immediately with empty fields<br>      }<br>    } catch (error) {<br>      console.error(&#39;❌ Synchronous error when trying to access HubSpotFormsV4 for fallback:&#39;, error); // Catch synchronous errors that might occur if HubSpotFormsV4 is truly unavailable<br>      pushHubSpotFormToDataLayer(formGuid, event.detail, {}); // Push with empty fields<br>    }<br>  }<br>});<br>&lt;/script&gt;</pre><h3>2- The following stage will be to create a trigger:</h3><p>Next, you’ll need to use the previous code as a a trigger.</p><p>For that, go to the <strong>Triggers</strong> section and click <strong>New</strong> -&gt; <strong>Trigger Configuration</strong> -&gt; choose <strong>Custom Event</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X5hVYig0xIAqqowcz7kGHg.png" /><figcaption>In the triggers&#39; menu, create a new trigger</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/494/1*MoNVaFi4ZJaWJ_kDSPoXQw.png" /><figcaption>It will be a Custom Event</figcaption></figure><p>In the <strong>Event Name</strong> field, enter hubspotFormSubmit (or any other name you wish, just update it on line 6 of the code above), then tick the <strong>All Custom Events</strong>. Then, give your trigger a name (e.g.,<em> Custom Event - HubSpot iframe form submission</em>) and save it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LIRiZ3TRIX8WIFnMSL5oJQ.png" /><figcaption>Once you have set up your trigger, it should look similar to this</figcaption></figure><h3>3-Create a new tag</h3><p>Create a new <strong>Google Analytics: GA4 Event </strong>and set the name of your choice, we opted for hubspot_v4_form_submit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FKbY46UiKV_cwjkvRgiQXw.png" /><figcaption>The new tag uses the trigger made from the custom event that was just created</figcaption></figure><p><em>Optional: you can get the form parameters, we added the </em>form ID<em> but you can take more or less of those parameters.</em></p><h3>Closing remarks</h3><p>The setup is now complete. As a best practice, please conduct thorough testing in GTM and or any other platform you use prior to deployment. If the test is successful in GTM, please note that conversion data may take up to 48 hours to appear in GA4.</p><p>We welcome your feedback. Let us know if you found this guidance helpful or if you have recommendations for improvement.</p><p>This article has been co-authored with Lucas Carval.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9f843a1ca200" width="1" height="1" alt=""><hr><p><a href="https://medium.com/agorapulse-stories/track-hubspot-breeze-ai-forms-submissions-with-google-tag-manager-9f843a1ca200">Track HubSpot Breeze AI forms submissions with Google Tag Manager</a> was originally published in <a href="https://medium.com/agorapulse-stories">Stories by Agorapulse</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to standardize GA4 data with dbt]]></title>
            <link>https://medium.com/agorapulse-stories/i-struggled-to-standardize-ga4-data-with-dbt-so-you-dont-have-to-22310f26240c?source=rss-97bc22dbece0------2</link>
            <guid isPermaLink="false">https://medium.com/p/22310f26240c</guid>
            <category><![CDATA[dbt]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[bigquery]]></category>
            <category><![CDATA[google-analytics-4]]></category>
            <category><![CDATA[data-pipeline]]></category>
            <dc:creator><![CDATA[Alberto Mendez]]></dc:creator>
            <pubDate>Wed, 16 Oct 2024 07:34:53 GMT</pubDate>
            <atom:updated>2024-10-17T08:54:11.280Z</atom:updated>
            <content:encoded><![CDATA[<p>Exporting GA4 data to BigQuery provides raw, unprocessed data nested in up to three levels that isn’t immediately ready for analysis. While many tutorials explain the basic connection process, few guide you through implementing a medallion data strategy — from transforming raw “bronze” data into a polished “gold” data mart that marketing teams can effectively use. There will be more detail in the upcoming section ‘Context’</p><p>In this article, we’ll guide you through setting up the GA4 to BigQuery connection, applying data transformations, and building refined tables ready for marketing insights. At Agorapulse, we’ve been through the trial and error, so you don’t have to — this is one solution we discovered through our journey. Let’s dive in and simplify the process for you!</p><h3>Context</h3><p>In the past months, we have been going through a transformation to achieve 2 objectives :</p><ol><li><strong>Have a clear pipeline of data transformation</strong><br>We set up a medallion architecture, from raw to refined. We made sure to implement a single source of truth. We tested and documented all of our models.</li><li><strong>Develop self-service data in the teams</strong><br>We chose Metabase, for its user-friendly interface.</li></ol><p>To give you more context, this is an overview of our new data pipeline :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yKV42pQ2odHhdGMvSlMqEw.png" /></figure><p>The data pipeline begins with ingestion from various sources, where the raw data is first loaded into BigQuery at the <strong>bronze layer</strong>. Next, the data undergoes cleaning and standardization, moving to the <strong>silver layer</strong>, where it’s stored in a dataset called standardized_data. Finally, the data is transformed into ready-to-use tables at the <strong>gold layer</strong>, making it fully prepared for analysis and reporting.</p><p>To achieve this, here is the data stack we use at Agorapulse</p><ul><li>Web analysis: GA4</li><li>Data warehouse: BigQuery</li><li>Data transformation: dbt (orchestrated by Airflow, but you can use dbt Cloud)</li><li>Visualization: Metabase</li></ul><h3>Step 1 : get the data from GA4 to BigQuery in the bronze layer</h3><p>This step is straightforward and can be achieved quickly if you have the appropriate permissions. Once access is set up, it typically only takes a few minutes to import the data. There are many guides available to help, and you can refer to <a href="https://www.youtube.com/watch?v=_EXMhejNK-Y">this video from minute 9</a> or <a href="https://www.optimizesmart.com/export-data-from-ga4-to-bigquery/">this article</a> if you prefer reading to watching.</p><p>Before diving into the data structure, it’s important to understand how GA4 identifies users. GA4 uses three primary methods to track user activity across different sessions and devices:</p><ul><li><strong>User ID</strong>: For platforms where users log in, GA4 can track them across sessions using the platform’s user ID. In our case, the Agorapulse app user ID.</li><li><strong>Google Signals</strong>: Uses activity from a user’s Google account to track them across devices.</li><li><strong>Device ID</strong>: The default method, based on the device being used, applied when neither a user ID nor Google Signals is available.</li></ul><p>Once imported, the data is stored in a dataset typically named analytics_XXXXXXXXX. This dataset is <strong>date-sharded</strong> and contains three main tables:</p><ul><li><strong>events</strong>: The largest table, holding almost all available data, including user interactions and event tracking.</li><li><strong>pseudonymous_users</strong>: A table more focus on user data, offering deeper insights such as audience segments and predictive data.</li><li><strong>users</strong>: Stores data tied to pseudonymous identifiers, such as user IDs. Non-consented user data can be exported here, provided it includes a user ID. This table will not exist if there is no possibility to log in in your website.</li></ul><p>Note : In this article, we will focus only on the events table.</p><h3>Step 2 : Flatten the nested data in the silver layer</h3><h4><strong>1-Declaring the source</strong></h4><p>So first, we need to declare the source in a .yml file.</p><p>This is how we have defined our yml file source_ga4_&lt;property_name&gt;_doc.yml to call the source and later be able to transform it :</p><pre>version: 2<br><br>sources:<br>  - name: ga4_website<br>    database: &lt;your_bigquery_project&gt;<br>    schema: &lt;analytics_XXXXXXXXX&gt;<br>    tables:<br>      - name: events_*</pre><p>Adapt the values between &lt; and &gt; to your values.</p><p><strong>2-Creating the model and standardizing the data in the silver layer</strong></p><p>The data contains nested fields, and the volume of data in GA4 is very large.</p><ul><li>Due to the nested columns, we decided to unpivot the rows into columns for easier future manipulation. This will flatten the data. To do this, we combined the UNNEST function with a LEFT JOIN operator and created new columns in the SELECT statement.</li><li>To limit the query costs and optimize the execution time, we have partitioned the table and made it incremental for data between 3 days ago and 2 days ago (because the data in GA4 can take up to 48h to arrive). Everyday, our model adds data from 3 days ago.</li><li>As we receive some duplicated events, we have decided to apply a window function (row_number) to deduplicate these events from this step.</li></ul><p>For the silver layer we have created the ga4_global_events.sql file which looks like this</p><pre>{{ config(<br>    materialized=&#39;incremental&#39;,<br>    on_schema_change = &#39;append_new_columns&#39;,<br>    partition_by={<br>      &quot;field&quot;: &quot;event_date&quot;,<br>      &quot;data_type&quot;: &quot;date&quot;,<br>      &quot;granularity&quot;: &quot;day&quot;<br>    }<br>) }}<br><br>WITH ga4_website_events AS (<br>  SELECT *<br>  FROM {{ source(&#39;ga4_website&#39;, &#39;events_*&#39;) }}<br>  WHERE _table_suffix BETWEEN FORMAT_DATE(&#39;%Y%m%d&#39;, DATE_SUB(CURRENT_DATE(), INTERVAL 3 DAY))<br>    AND FORMAT_DATE(&#39;%Y%m%d&#39;, DATE_SUB(CURRENT_DATE(), INTERVAL 2 DAY))<br>),<br><br>final AS (<br>  SELECT<br>    collected_traffic_source.manual_campaign_id                        AS utm_campaign_id,<br>    collected_traffic_source.manual_campaign_name                      AS utm_campaign,<br>    collected_traffic_source.manual_source                             AS utm_source,<br>    collected_traffic_source.manual_medium                             AS utm_medium,<br>    collected_traffic_source.manual_term                               AS utm_term,<br>    collected_traffic_source.manual_content                            AS utm_content,<br>    device.category                                                    AS device_category,<br>    PARSE_DATE(&#39;%Y%m%d&#39;, ga4_website_events.event_date)                AS event_date,<br>    TIMESTAMP_MICROS(ga4_website_events.event_timestamp)               AS event_timestamp,<br>    ga4_website_events.event_name                                      AS event_name,<br>    ep_page_location.value.string_value                                AS page_location,<br>    ep_page_title.value.string_value                                   AS page_title,<br>    ep_page_session_engaged.value.string_value                         AS session_engaged,<br>    ep_page_ga_session_number.value.int_value                          AS ga_session_number,<br>    ep_page_engagement_time_msec.value.int_value                       AS engagement_time_msec,<br>    ep_page_value.value.int_value                                      AS page_value,<br>    ep_page_gclid.value.string_value                                   AS gclid,<br>    ep_page_link_classes.value.string_value                            AS link_classes,<br>    ep_page_link_domain.value.string_value                             AS link_domain,<br>    ep_page_link_url.value.string_value                                AS link_url,<br>    CAST(ep_batch_page_id.value.int_value AS STRING)                   AS batch_page_id,<br>    ep_batch_ordering_id.value.int_value                               AS batch_ordering_id,<br>    ep_ga_session_id.value.int_value                                   AS ga_session_id,<br>    ep_page_page_referrer.value.string_value                           AS page_referrer,<br>    ep_engaged_session_event.value.string_value                        AS engaged_session_event,<br>    ep_page_ignore_referrer.value.string_value                         AS ignore_referrer,<br>    ep_traffic_type.value.string_value                                 AS traffic_type,<br>    ep_click_url.value.string_value                                    AS click_url,<br>    geo.continent                                                      AS continent,<br>    geo.sub_continent                                                  AS sub_continent,<br>    geo.country                                                        AS country,<br>    geo.city                                                           AS city,<br>    ga4_website_events.is_active_user                                  AS is_active_user,<br>    ga4_website_events.platform                                        AS platform,<br>    traffic_source.name                                                AS traffic_source_name,<br>    traffic_source.medium                                              AS traffic_source_medium,<br>    traffic_source.`source`                                            AS traffic_source_source,<br>    TIMESTAMP_MICROS(ga4_website_events.user_first_touch_timestamp)    AS user_first_touch_at,<br>    ga4_website_events.user_pseudo_id                                  AS user_pseudo_id,<br>    CASE WHEN privacy_info.analytics_storage = &#39;Yes&#39; THEN 1 ELSE 0 END AS has_consented_to_tracking,<br>  FROM ga4_website_events<br>  LEFT JOIN UNNEST(ga4_website_events.event_params) AS ep_page_location ON ep_page_location.`key` = &#39;page_location&#39;<br>  LEFT JOIN UNNEST(ga4_website_events.event_params) AS ep_page_title ON ep_page_title.`key` = &#39;page_title&#39;<br>  LEFT JOIN UNNEST(ga4_website_events.event_params) AS ep_page_session_engaged ON ep_page_session_engaged.`key` = &#39;session_engaged&#39;<br>  LEFT JOIN UNNEST(ga4_website_events.event_params) AS ep_page_ga_session_number ON ep_page_ga_session_number.`key` = &#39;ga_session_number&#39;<br>  LEFT JOIN UNNEST(ga4_website_events.event_params) AS ep_page_page_referrer ON ep_page_page_referrer.`key` = &#39;page_referrer&#39;<br>  LEFT JOIN UNNEST(ga4_website_events.event_params) AS ep_page_ignore_referrer ON ep_page_ignore_referrer.`key` = &#39;ignore_referrer&#39;<br>  LEFT JOIN UNNEST(ga4_website_events.event_params) AS ep_page_engagement_time_msec ON ep_page_engagement_time_msec.`key` = &#39;engagement_time_msec&#39;<br>  LEFT JOIN UNNEST(ga4_website_events.event_params) AS ep_page_value ON ep_page_value.`key` = &#39;value&#39;<br>  LEFT JOIN UNNEST(ga4_website_events.event_params) AS ep_page_gclid ON ep_page_gclid.`key` = &#39;gclid&#39;<br>  LEFT JOIN UNNEST(ga4_website_events.event_params) AS ep_page_link_classes ON ep_page_link_classes.`key` = &#39;link_classes&#39;<br>  LEFT JOIN UNNEST(ga4_website_events.event_params) AS ep_page_link_domain ON ep_page_link_domain.`key` = &#39;link_domain&#39;<br>  LEFT JOIN UNNEST(ga4_website_events.event_params) AS ep_page_link_url ON ep_page_link_url.`key` = &#39;link_url&#39;<br>  LEFT JOIN UNNEST(ga4_website_events.event_params) AS ep_batch_page_id ON ep_batch_page_id.`key` = &#39;batch_page_id&#39;<br>  LEFT JOIN UNNEST(ga4_website_events.event_params) AS ep_batch_ordering_id ON ep_batch_ordering_id.`key` = &#39;batch_ordering_id&#39;<br>  LEFT JOIN UNNEST(ga4_website_events.event_params) AS ep_ga_session_id ON ep_ga_session_id.`key` = &#39;ga_session_id&#39;<br>  LEFT JOIN UNNEST(ga4_website_events.event_params) AS ep_engaged_session_event ON ep_engaged_session_event.`key` = &#39;engaged_session_event&#39;<br>  LEFT JOIN UNNEST(ga4_website_events.event_params) AS ep_traffic_type ON ep_traffic_type.`key` = &#39;traffic_type&#39;<br>  LEFT JOIN UNNEST(ga4_website_events.event_params) AS ep_click_url ON ep_click_url.`key` = &#39;click_url&#39;<br>  -- We added this to remove duplicated events. Weirdly, we sometimes receive 2 identical rows.<br>    QUALIFY ROW_NUMBER() OVER (PARTITION BY<br>      ga4_website_events.batch_page_id,<br>      ga4_website_events.batch_ordering_id,<br>      ga4_website_events.event_name,<br>      ga4_website_events.event_timestamp,<br>      ep_page_ga_session_number.value.int_value,<br>      ep_page_location.value.string_value,<br>      ep_page_value.value.int_value,<br>      ep_traffic_type.value.string_value,<br>      ga4_website_events.user_pseudo_id) = 1<br>)<br>SELECT<br>  batch_ordering_id,<br>  batch_page_id,<br>  city,<br>  click_url,<br>  continent,<br>  country,<br>  device_category,<br>  engagement_time_msec,<br>  engaged_session_event,<br>  event_date,<br>  event_name,<br>  event_timestamp,<br>  ga_session_id,<br>  ga_session_number,<br>  gclid,<br>  has_consented_to_tracking,<br>  is_active_user,<br>  ignore_referrer,<br>  link_classes,<br>  link_domain,<br>  link_url,<br>  page_location,<br>  page_title,<br>  page_referrer,<br>  page_value,<br>  session_engaged,<br>  sub_continent,<br>  traffic_source_medium,<br>  traffic_source_name,<br>  traffic_source_source,<br>  traffic_type,<br>  user_first_touch_at,<br>  user_pseudo_id,<br>  utm_campaign,<br>  utm_campaign_id,<br>  utm_content,<br>  utm_medium,<br>  utm_source,<br>  utm_term<br>FROM final<br>{% if is_incremental() %}<br>  WHERE event_date &gt; (SELECT MAX(this.event_date) FROM {{ this }} AS this)<br>{% endif %}</pre><h3>Step 3 : create tables for self-service use in the gold layer</h3><p>In our medallion data pipeline, the creation of data marts is at the end of the pipeline, in the gold layer. These tables will be used by our marketing team in self-service in Metabase, so their structure and columns need to be user-friendly and ready to use. The key tables include:</p><ul><li>Events table</li><li>New users table</li><li>Page views table</li><li>Sessions table</li></ul><p>Below is an example of the code for the events table &lt;ga4_property_name&gt;_events.sql:</p><pre>{{ config(<br>    materialized=&#39;incremental&#39;,<br>    on_schema_change = &#39;append_new_columns&#39;,<br>    partition_by={<br>      &quot;field&quot;: &quot;event_date&quot;,<br>      &quot;data_type&quot;: &quot;date&quot;,<br>      &quot;granularity&quot;: &quot;day&quot;<br>    }<br>) }}<br><br>SELECT<br>    batch_page_id,<br>    city,<br>    continent,<br>    country,<br>    device_category,<br>    domain_type,<br>    engaged_session_event,<br>    engagement_time_msec,<br>    event_date,<br>    event_name,<br>    event_timestamp,<br>    ga_session_id,<br>    has_consented_to_tracking,<br>    page_location,<br>    session_engaged,<br>    sub_continent,<br>    traffic_source_medium,<br>    traffic_source_name,<br>    traffic_source_source,<br>    url_category,<br>    url_language,<br>    user_first_touch_at,<br>    user_pseudo_id,<br>    utm_campaign,<br>    utm_campaign_id,<br>    utm_content,<br>    utm_medium,<br>    utm_source,<br>    utm_term<br>FROM {{ ref(&#39;ga4_global_events&#39;) }}<br>{% if is_incremental() %}<br>  WHERE event_date &gt; (SELECT MAX(event_date) FROM {{ this }})<br>{% endif %}</pre><p>Here is the code for the page views table &lt;ga4_property_name&gt;_page_views.sql :<br><em>note that the code is the same as above, we just added a filter event_name = &#39;page_view&#39;</em></p><pre>{{ config(<br>    materialized=&#39;incremental&#39;,<br>    on_schema_change = &#39;append_new_columns&#39;,<br>    partition_by={<br>      &quot;field&quot;: &quot;event_date&quot;,<br>      &quot;data_type&quot;: &quot;date&quot;,<br>      &quot;granularity&quot;: &quot;day&quot;<br>    }<br>) }}<br><br>SELECT<br>    batch_page_id,<br>    country,<br>    city,<br>    event_date,<br>    domain_type,<br>    engagement_time_msec,<br>    engaged_session_event,<br>    event_name,<br>    event_timestamp,<br>    ga_session_id,<br>    device_category,<br>    url_language,<br>    page_location,<br>    continent,<br>    has_consented_to_tracking,<br>    session_engaged,<br>    sub_continent,<br>    traffic_source_medium,<br>    traffic_source_name,<br>    traffic_source_source,<br>    utm_campaign,<br>    utm_campaign_id,<br>    utm_content,<br>    utm_medium,<br>    utm_source,<br>    utm_term,<br>    user_pseudo_id,<br>    user_first_touch_at<br>  FROM {{ ref(&#39;ga4_global_events&#39;) }}<br>{% if is_incremental() %}<br>  WHERE event_name = &#39;page_view&#39; AND event_date &gt; (SELECT MAX(this.event_date) FROM {{ this }} AS this)<br>{% endif %}</pre><p>If you are using dbt, don’t forget to document all these new tables along the way in the respective .yml files.</p><p>Congratulations ! You have finished the data transformation process and the GA4 data is ready to be used !</p><h3>Start building charts with the refined tables and get actionable insights</h3><p>Once the data is prepared, you can begin delivering meaningful insights to your marketing teams. Here are some examples of visualizations you can create:</p><ul><li>Trends in unique users and page views</li><li>Trends in unique sessions</li><li>Trends in new visitors</li><li>User distribution by device category</li><li>100% stacked bar chart for page traffic by language</li><li>100% stacked bar chart for page traffic by category</li></ul><p>Here is an example :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M_57tKgErniY39lzYHvToA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2N5Lis-eWUiAkYDVQob-hA.png" /></figure><p>If you have followed these steps, you just built a GA4 data pipeline and refined it to a business use, kudos to you !</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=22310f26240c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/agorapulse-stories/i-struggled-to-standardize-ga4-data-with-dbt-so-you-dont-have-to-22310f26240c">How to standardize GA4 data with dbt</a> was originally published in <a href="https://medium.com/agorapulse-stories">Stories by Agorapulse</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>