Sub topic 2
How GA4 Marks Traffic with `traffic_type`
This chapter assumes you have a GA4 web data stream, Editor or Administrator access, and a basic understanding of events and sessions. You should also know the public IP address used by your office or test network.
What `traffic_type` means
GA4 collects data as events. An event is a recorded action, such as a page view, click, or purchase. Each event can include parameters, which are extra pieces of information describing that action.
traffic_type is an event parameter used to label traffic that matches an internal traffic rule. GA4 commonly uses the value internal. The label does not remove anything by itself. A property-level data filter must use the label to exclude matching events.
This creates a two-step process:
- A traffic rule recognizes a visitor or event.
- A data filter acts on the
traffic_typevalue.
For example, your office traffic might be labeled traffic_type=internal. While the filter is inactive, those events can still appear in reports. After you activate an internal traffic filter, GA4 excludes matching events from the property’s reporting data.
How the label is added
In the GA4 interface, an internal traffic rule usually checks a condition such as an IP address. When the condition matches, GA4 adds the selected traffic_type value to collected events.
The value is normally internal, but a rule can use another value when your organization needs separate categories. For example, you might use office, agency, or qa. The data filter must use exactly the same value, including capitalization.
You can also set the parameter in a Google tag configuration. This approach is useful when you control the tagging code and want to label a page load or another known source directly.
gtag('config', 'G-XXXXXXXXXX', {
'traffic_type': 'internal'
});This configuration applies the label to events collected from that page load through the tag setup. Replace G-XXXXXXXXXX with your measurement ID. The code belongs after the Google tag has been installed and after the gtag function has been defined.
Rule labels and event scope
The traffic rule is evaluated while GA4 receives the event. The resulting label belongs to the event, not permanently to the person or browser. A visitor can therefore produce both internal and non-internal events if the visitor changes networks or uses a different device.
The label also differs from a traffic source. A traffic source describes where a session came from, such as Google Search, an email campaign, or another website. traffic_type describes a classification applied during collection. It does not replace the session’s source or medium.
Common errors
- Creating a rule but never creating or activating its matching data filter. The events are labeled, but they are not excluded.
- Using
internalin the rule andInternalin the filter. Values must match exactly. - Treating
traffic_typeas retroactive. Events collected before the rule or filter change are not relabeled. - Setting the parameter manually in one tag while expecting unrelated tags or server-side events to receive it.
- Assuming an office label follows employees outside the office network. IP-based matching depends on the network used when the event is sent.
Worked example
Suppose your office uses a fixed public address. You create an internal traffic rule that matches that address and assigns traffic_type=internal. An employee loads the website from the office. GA4 receives the page-view event with that parameter. The internal traffic data filter then determines whether the event remains available or is excluded.
A home visit from the same employee does not match the office rule. That event has no internal label unless another rule or tag adds one.
Exercise
What does GA4 do when an event matches an internal traffic rule?
Show answer
It adds the rule's traffic_type value, commonly internal, to the event. A separate data filter must exclude the event.