DataStudio how to create a Google Analytics Custom Channel Grouping

Google DataStudio is an excellent addition to the Google Suite tool arsenal which deals with the reporting / exploration part.  A much more complex system than what we are used to with Google Analytics Dashboards yet still really easy to use! The product is still in Beta but looks very promising.

For more information about DataStudio here are some useful links to get you up and running:

  1. Product overview –
  2. Help center –
  3. Creating a report (case) –

Back to the issue at hand:

How to create a Google Analytics Custom channel grouping inside DataStudio

Most of avid Google Analytics users are really keen on redefining the default channel grouping or adding custom channel grouping to have a better understanding of how ‘channels’ perform on a high / low detail level. Unfortunately GA Reporting API / Core API still does not have such a dimension exposed / available so in our reporting and analysis effort we have to resort to recreating the conditions with filtering. Same process has to be applied when reporting in DataStudio. So, whenever you want to widen the Default channel grouping by creating a Custom Channel grouping inside GA and want this to be accessible via DataStudio you need to do this:

  1. Add a data source – Google Analytics – procedure described in links above
  2. Add a custom field to the data source – which I will describe next

To begin with here is the official support for calculated fields –

Step 1
Create the field
04 datastudio create a calculated field


Step 2
The formula

07 datastudio building blocks


This is the tricky part. You need to mimic the order and definitions as you would in the GA Admin interface using prebuild DataStudio functions (  The basis will be the function CASE ( which uses this simple syntax:


This will translate to:

WHEN our source or campaign matches ‘some string’ THEN the dimension output will be ‘desired channel grouping dimension value’
ELSE if we missed to group some traffic inside a group it will output ‘You missed this’

The best way to proceed is to open Notepad or similar text editor and do it there as DataStudio formula entry has auto fill feature and you can only write in a single line so it will eventually strat to be extremely hard to track what is defined or what needs to be corrected.

‘Referral’ channel group
WHEN Default Channel Grouping = “Referral” THEN “Referral”

‘Paid listings’ channel group
REGEXP_MATCH(Medium, “.*(listing|xyz).*”) AND REGEXP_MATCH(Source, “.*(tripadvisor|abc).*”) THEN “Paid Listings”
In this case we are using REGEXP_MATCH function where we evaluate Medium AND Source for phrases we use when creating Custom Channel Grouping in Google Analytics.  We can also use other logical operators to create a more complex condition. Please note that REGEX we are used to in Google Analytics does not behave the same as in DataStudio (after some tinkering guys from confirmed it – thanks!)  – more on DS regex –

Your end result should have the following structure:

WHEN Default Channel Grouping = “Referral” THEN “Referral”
WHEN Default Channel Grouping = “Direct”  THEN “Direct”
WHEN Medium = “cpc” AND REGEXP_MATCH(Campaign, “.*(brand|bcmp).*”) THEN “Paid Brand Campaign”
WHEN REGEXP_MATCH(Medium, “.*(listing|xyz).*”) AND REGEXP_MATCH(Source, “.*(tripadvisor|abc).*”) THEN “Paid Listings”
… add more definitions as you see fit
ELSE “Other”

Copy your entire code and paste it inside the formula field:

05 datastudio fill in the formula

Step 3
Update the data source

07 update data source



Step 4
Change the Dimension in your widget from Default Channel grouping to your Custom Channel grouping one.

Click on the current dimensions.
09 choose the calculated field

Choose the newly created one.

10 My custom channel grouping

A small hint – add a secondary dimensions – Source / Medium just to check if all the traffic is indeed in predefined and expected channel group.

11 make sure it is applied

Step 5
Refresh the data

12 refresh the data


Final notes:

  • Any change you do inside GA should be redone inside DataStudio Custom field (at least till GA surfaces some kind of a custom channel grouping dimension via API)
  • The same approach can be used for any kind of filtering / segmentation and once you get used to the syntax it is pretty useful and offers nice customization options


Author bio

Zorin Radovančević

August 26, 2016 Google Analytics

Senior Web Analytics implementation and planning specialist - all things related to Google Analytics, Google Tag Manager and Yandex Metrica.


Leave a Reply

Your email address will not be published. Required fields are marked *