Skip to content
Tips & tricks

Group your GA4 data: Data import or Data Studio?

Do you want to read your GA4 reports using your own groupings, such as a business unit, a product category or a content section? I'll show you 2 ways to get there without heavy configuration, Data import and rules in Data Studio and when to prefer one or the other.

Alexis Neve 5 min read

Why group your GA4 data

GA4 delivers the data as your site sends it. However, your teams often need more customised reports with, notably, their own groupings. And that is entirely possible! Start with a small mapping table and a suitable method.

2 methods to import data:

  • Data import: a CSV file is imported into Google Analytics, which links it to its data. The groupings then appear in the tool itself and its native reports.
  • Rules in Data Studio: a calculated field applies the mapping in a report, without touching GA4. These rules remain more general and may not cover every particular case, unless you stack up the conditions...

The typical grouping case

Most of the time, it is a small table of a few dozen, even a few hundred rows, to cross with your Google Analytics data: business units, product colours, file themes, areas of expertise, product categories... There is a multitude of groupings, it all depends on your needs.

Method 1: GA4 Data import with a CSV file

The CSV file is the easiest format to master. It contains one column with the GA4 value (the common key, for example a product ID or a page URL) and one column with your grouping. The setup follows 4 steps:

  1. In GA4, create the event-scoped custom dimension that will receive the grouping.
  2. Prepare the CSV mapping file.
  3. Configure the data source in GA4 and submit the file.
  4. Wait up to 24h for processing, then use the dimension in your reports and explorations.

Since GA4 links the file when the report is opened, the grouping also applies to the history!

Method 2: rules in Data Studio

Google Data Studio (a free tool, by the way) applies the mapping inside its own reports, with a calculated field of type CASE (others exist but this one is the most practical). This field reads a dimension and returns a label, because the mapping table is written directly in the formula.

Create the calculated field

  1. In the report, open Resource > Manage added data sources then edit the GA4 source.
  2. Choose Add a field to create the field in the source: it will be available in all the charts of the report. If you create the field from a chart, it stays limited to that chart.
  3. Name the field after what it represents ("Business unit").
  4. Write the formula, for example:
CASE
  WHEN Country IN ("Belgium", "Luxembourg", "Netherlands") THEN "Benelux"
  WHEN Country = "France" THEN "France"
  WHEN Country IN ("Germany", "Spain", "Italy") THEN "Export"
  ELSE "Others"
END
  1. Save, then use the new field as a dimension in a table or a chart.

Moreover, the field applies to all the data of the period displayed, including the history, because the calculation is done at display time.

Formula variants

When the mapping relies on a pattern rather than an exact value, 2 functions cover most cases:

CASE
  WHEN STARTS_WITH(Session campaign, "be_") THEN "Benelux"
  WHEN STARTS_WITH(Session campaign, "fr_") THEN "France"
  WHEN REGEXP_MATCH(Session campaign, ".*(promo|sales).*") THEN "Promotions"
  ELSE "Others"
END

In the age of AI, I advise you to describe your need to Gemini or ChatGPT, which will write you an optimised formula suited to your case. Just remember that the conditions are evaluated in order and that the first one that is true wins. So place the specific cases before the broad ones.

Check the mapping

A formula that saves without error can still classify rows in the wrong place. Look at the share of "Others": a high value signals a non-exhaustive formula. Expand the row to read the original values and fix your conditions.

The limits of Data Studio rules

The mapping lives only in the Data Studio report, so nowhere else:

  • It is absent from GA4: neither in the standard reports nor in the explorations.
  • It is also absent from audiences. A "Benelux customers" audience must be built on the original dimension (the country).
  • Finally, it is absent from the BigQuery export and from other reports that use another source.

Pitfalls

  • Case and spaces. "Belgium" and "belgium" are 2 different values in a string comparison. Check the real values in a table before writing the formula, or pass the original dimension through LOWER().
  • "(not set)" values. They fall into the ELSE, so provide a dedicated label to spot them.
  • The total to compare. Display the table by "Business unit" and compare the sum of sessions with the total of the same period without the dimension. The 2 figures must be identical, since the field distributes the rows without removing any.

Data import or Data Studio: the comparison

CriterionGA4 Data import (CSV)Data Studio rules
Number of rowsLonger table possibleA few dozen conditions, beyond that the formula becomes unreadable
Reading in GA4 (reports, explorations)PossibleImpossible
Frequency of changeNew file import, processing delayChange in 1 minute in the report
Permissions requiredProperty administrationReport editing
Effect on historyYes, for custom event data importYes, at display time

The rule: if the mapping is only used to read a report, the table is small and it changes often, Data Studio rules are enough. If it must serve a GA4 exploration or several teams who work in GA4, Data import is the answer.

Moving from Data Studio rules to Data import

If the mapping must one day exist in GA4, the CASE formula has already laid the foundation of the table: each WHEN becomes a row of the CSV file, with the GA4 value on one side and the label on the other. You therefore already have the table ready to import as a CSV!

Tools

  • Data Studio: CASE, STARTS_WITH, REGEXP_MATCH calculated fields.
  • Google Analytics 4: custom event data import, event-scoped custom dimensions.

Building reports that management can read is part of the dashboards expertise.

Ready to take action?

Tell me about your site and your Ads platforms: you get a clear answer within 48 hours.

Get a quote