---
# System prepended metadata

title: Channel Grouping - Google Anal

---

# Channel Grouping - Google Analytics


Hi guys,

After transitioning to Google Analytics 4 (GA4), you will indeed find two types of reports in the "Channel" section. These reports are known as:
**User acquisition: First user default channel grouping**
![](https://hackmd.io/_uploads/ByfzI4ZZa.png)

**Traffic acquisition: Session default channel grouping**
![](https://hackmd.io/_uploads/SJQNINWZa.png)

It's evident that in the Traffic Acquisition section, the "Unassigned" category has a higher count than "User Acquisition." Additionally, when comparing GA3 and GA4, the "Direct" channel in the "User Acquisition" tab of GA4 surpasses the same channel in GA3.

Let's now delve into a session to explore when and why you should use each report and how to replicate the GA3 report in GA4.

In hittime and user level, the data structure like this picture below of clientid = '33197926.1693534740'
![](https://hackmd.io/_uploads/rkcqMHZWp.png)


This particular user visited the website https://hellobacsi.com/health-tools/cach-tinh-chi-so-bmi/ on September 1, 2023, at 02:19:06 UTC. Their visit originated from Google's search engine (source 'google') through organic search (medium 'organic').

During their session, the user engaged with multiple articles and eventually signed up for an account.

In the analytics data, you may notice that some hit numbers have null values for source, medium, and campaign. This is due to the new tracking approach in GA4, which relies on events and hit time (hittimutc). As a result, certain hit times might be null.

Additionally, GA4's channel grouping follows a rule where if both source and medium are null, the traffic is categorized as "Direct." This can lead to an apparent increase in Direct traffic in the User Acquisition and Traffic Acquisition reports, even though it may not necessarily be direct traffic.

In specific BigQuery traffic tables like tools_traffic, together_traffic, and registered_users_traffic, you will encounter many null values for source and medium. This is because these tables are designed to collect traffic data for specific actions or segments. For example, tools_traffic collects data only from page paths containing "%/health-tools/%" or "%/bot/%," while registered_users_traffic is exclusively sourced from registered user traffic.

You can try this script
```
SELECT distinct
  source,medium,count(distinct clientid) as no_users
FROM
  `hhg-cdm.hhg_marketing_ga.hhg_ga4_sessions_di`
WHERE
  date = "2023-09-01"
  AND country_code = "VN"
  AND web_page = "Hello Bacsi"
  and (pagepath like "%/health-tools/%" or pagepath like "%/bot/%")
group by 1,2 order by 3 desc
```

Result:
![](https://hackmd.io/_uploads/HkEavB-bp.png)
418 users from null source and null medium --> 418 users from Direct

To make it correct, it should be
```
SELECT distinct
  source,medium,count(distinct clientid) as no_users
from ( select channelgrouping,
    clientid,pagepath,
    max(source) over(partition by date, clientid,session_id) as source, 
    max(medium) over(partition by date, clientid,session_id) as medium, 
    max(campaign) over(partition by date, clientid,session_id) as campaign
FROM
  `hhg-cdm.hhg_marketing_ga.hhg_ga4_sessions_di`
WHERE
  date = "2023-09-01"
  AND country_code = "VN"
  AND web_page = "Hello Bacsi") where (pagepath like "%/health-tools/%" or pagepath like "%/bot/%")
group by 1,2 order by 3 desc
```
Result:
![](https://hackmd.io/_uploads/ByFF_rb-a.png)
Now 260 users from Google Organic, 114 from Direct!

To recreate a report similar to Google Analytics (GA) 3 using Google Analytics 4 (GA4), you can use the following script to obtain session-level data for channel grouping.
```
SELECT channelgrouping,
count(distinct clientid) as total_users
FROM 
(
  select channelgrouping,
    clientid,
    max(source) over(partition by date, clientid,session_id) as source_per_sessions, 
    max(medium) over(partition by date, clientid,session_id) as medium_per_sessions, 
    max(campaign) over(partition by date, clientid,session_id) as campaign_per_sessions
  from
    `hhg-cdm.hhg_ops_user.hhg_registered_users_traffic_di`
  where date >= current_date() -30
  and country_code = "VN" and web_page = "Hello Bacsi"
)
group by channelgrouping order by total_users desc
```

To be easier for BI to use, DE will create source_per_session, medium_per_session, campaign_per_session, keyword_per_session, adcontent_per_session in all traffic table.

Cheers,