[GA4] Tagging best practices to avoid unassigned, (not set), and direct traffic issues

Google Analytics 4 tags have several configuration options that can affect session and user identity. If they are not correctly configured, it can lead to traffic sources not being able to be identified or categorized, and other issues in reports. These issues lead to unassigned rows in channel groups in reports, (not set) values, and an unexpectedly large portion of traffic categorized as direct.

In Google Analytics 4 reports, the unassigned row appears when Analytics cannot categorize the source of traffic. Analytics categorizes traffic sources into channels based on fixed rules. For example, the Organic Search channel includes traffic from all search engines. Channels are organized into channel groups. If you are using the default channel groups, you can review the specific logic that categorizes traffic in the Default channel definitions. Channel groups can be viewed at the user, session or event level.

When a traffic source doesn't fit the definition of one of the channels in a channel group you're viewing in a report, it is shown as unassigned. There may be no predefined rule to categorize a traffic source if your traffic comes from a user-defined source or medium, or is (not set) because it is missing session or user identity information.

Best practices for tag code ordering

Follow these recommended tag code ordering best practices:

Tag type Instructions Best practices

Google tag

Configure Google products and send event data

Initialize the Google tag before calling an event method including audience-triggered events.

Google Tag Manager

Set up Google Tag Manager

Google Tag Manager for web pages

About Google Tag Manager

Follow the 4 steps to set up GTM

Server-side tagging

Server-side - Tag Manager

Be sure not to skip these specific tag settings.

You should not maintain both a server-side and a standalone client-side implementation on the same page for the same GA4 property. If you're using sGTM, ensure that all your active tags are set up to send events through the server-side container.

If you can't follow the recommended ordering practice for events, you should still follow these two recommendations. If you do not, expect issues in reporting.

  • Provide all relevant configuration for the page as part of the config command (for Google tag) or the Google tag settings (for Google Tag Manager) as early as possible on the page, and before any events.
  • Custom events should not be fired before the config command, or they will be batched with the session_start event. The config command can affect user and session identity for the rest of the page; meaning the page view and later events cannot be associated with the earlier session start and custom event.

What happens if my events aren’t ordered correctly?

When GA4 tags are set at unexpected times, for example if the config command or Google tag fires after other events in the page, it can affect user ID, session ID, or both. This can result in:

  • Data appearing as (not set)in Analytics
  • Incorrect user and session counts
  • User and session level metrics not being calculated correctly
  • Improper user and session measurement

What can cause events to be ordered incorrectly?

Common known causes of unexpected timing include:

Feature Cause Result Best practices

Server-side tagging

Server managed setting (server managed client ID)

Client managed settings
(transport_url, first_party_collection, server_container_url)

Checking the server-side tagging box for "Server Managed Setting," which is on by default.

When GA4 events are processed through a server tag, users have a range of options for using a different user identity than the client ID used by the web tag.

Setting "Server Managed" in the top drop down means that server-side tagging will manage a separate client ID and substitute it for measurements it processes. It also enables several options for how that cookie is written, and an over-time migration option for customers that have existing GA direct traffic and don't want a hard break in audiences and reports by suddenly changing all their visitor's IDs at one moment in time.

If you use this option, you must ensure that all measurement for your stream flows through your server tag, and none is sent directly to Google servers.

The easiest way to do this is to ensure that the Google Tag Manager or config command (Google tag) for the web tag that sends data to your server container is always the first tag or command for that container.

Cookie name customization
(cookie_prefix)

This changes the name of the first party cookie used for both client ID and session state.

Users cannot be tied across sessions,and events cannot be included in sessions.

Event metrics appear as (not set) when analyzed with session or user dimensions.

Use one consistent cookie prefix across your site. The suggested use for the cookie prefix in Analytics is to create a customized cookie name, not to create multiple silos of cookies, which is what happens if you use different or inconsistent prefixes.

Automatic cross-domain linker
(linker)1

This setting tells the tag to process and begin using client and session data from the previous page, if available. When adopting the linked data, the tag assumes the session was already started on the previous page.

If the linker is initialized late and finds out about a cross-domain linked user through a late config command, then user identity will suddenly change at that point.

At minimum, late config commands result in short sessions that are discarded when the linker parameter values are adopted. Any session or user attributes already sent at that point can no longer be associated with the real session or user.

Don't customize client or session ID, as this leads to broken assumptions in both tags and processing about how sessions will be structured, and can also lead to issues.

Manual cross-domain linker
(client_id, session_id)

To allow customers to implement cross-domain measurement manually, the GA4 tag has APIs to get and set both client and session IDs. Inadvertently modifying client_id and session_id from their auto-generated values impacts how GA4 events are tied to users and sessions.

Events that are dissociated from their original client and session IDs may lack important information and cause unexpected attribution issues.

Use user_id to provide a custom user identity.

Don't use these APIs to modify or provide custom client or session IDs. These IDs should only be manually set in rare cases when cross-domain manual setup is necessary.

 

1 linker is the parameter from automated cross-domain linking. There is an option to manually set client ID and session ID if automated cross-domain linking does not work for your website. Never customize these values. GA4 expects values in a certain format, and unexpected values can lead to breakages. Learn more about the linker parameter.

Was this helpful?

How can we improve it?
Search
Clear search
Close search
Google apps
Main menu
4607519325182119904
true
Search Help Center
true
true
true
true
true
69256
true
false