Google Analytics 4 model

Channel Traffic Overview

This SQL template provides a monthly overview of channel traffic from Google Analytics, summarizing metrics such as total users, sessions, engaged sessions, events per session, engagement rate, event count, conversions, total revenue, and user engagement duration, grouped by channel.

Grain
See the notes
Built from
  1. 1
    Raw tables
  2. 1
    Core
  3. 1
    Analytics
Reads from Google Analytics 4
channel_traffic
Ships as
Weld and dbt SQL, open source on GitHub
core.google_analytics_4.channel_traffic_overview
1-- core.google_analytics_4.channel_traffic_overview
2-- Channel Traffic Overview. This SQL template provides a monthly overview of
3-- channel traffic from Google Analytics, summarizing metrics such as total users,
4-- sessions, engaged sessions, events per session, engagement rate, event count,
5-- conversions, total revenue, and user engagement duration, grouped by channel.
6--
7-- From the weld.app template library. Not reconciled against Google Analytics 4;
8-- check the output against the source before relying on it.
9
10SELECT
11  DATE_TRUNC(date, MONTH) AS period,  -- Change to 'DAY' for daily overview
12  session_default_channel_grouping AS channel,
13  SUM(total_users) AS total_users,
14  SUM(sessions) AS sessions,
15  SUM(engaged_sessions) AS engaged_sessions,
16  AVG(events_per_session) AS events_per_session,
17  AVG(engagement_rate) AS engagement_rate,
18  SUM(event_count) AS event_count,
19  SUM(conversions) AS conversions,
20  SUM(total_revenue) AS total_revenue,
21  SUM(user_engagement_duration) AS user_engagement_duration
22FROM
23  {{raw.google_analytics_4.channel_traffic}}
24GROUP BY
25  period, channel
26ORDER BY
27  total_users DESC

This model and the 1 it depends on. Deploy them together; refs like {{staging.…}} resolve to the matching folders in Weld, and the dbt view uses source() and ref().

Notes

How it counts. And where it stops.

The "Channel Traffic Overview" SQL model provides a comprehensive summary of traffic data from Google Analytics. By aggregating data on a monthly basis (modifiable to daily), it offers insights into various metrics segmented by traffic channels. This model is useful for understanding user behavior and engagement across different channels, tracking the performance of marketing campaigns, and identifying the most effective channels in driving traffic and revenue. Key metrics include total users, sessions, engaged sessions, events per session, engagement rate, event count, conversions, total revenue, and user engagement duration. This information can help businesses optimize their marketing strategies and improve user engagement.

Raw tables it reads

  • raw.google_analytics_4.channel_traffic

Put Google Analytics 4 in front
of your agents.

Connect Google Analytics 4, deploy the models, and ask questions in Claude, Cursor or ChatGPT. Free for 14 days, no credit card.