Google’s free Data Studio tool is amazing for visualizing and reporting on your data. It also plays very well with other Google tools, like Google Ads and Google Analytics. However, it does have some limitations. One of those limitations is that it cannot pull in your custom channel groupings from Google Analytics.
Fortunately, all is not lost as you can use Data Studio’s calculated fields feature to build your own custom channel mappings in Data Studio. Inside your Google Analytics source, set up a calculated field. Then, input the code below:
CASE
WHEN ((Source=”direct” AND Medium=”(not set)”) OR Medium=”(none)”) THEN “Direct”
WHEN Medium=”organic” THEN “Organic Search”
WHEN (Social Source Referral=”Yes” OR REGEXP_MATCH(Medium,”^(social|social-network|social-media|sm|social network|social media)$”)) THEN “Social”
WHEN Medium=”email” THEN “Email”
WHEN Medium=”affiliate” THEN “Affiliates”
WHEN Medium=”referral” THEN “Referral”
WHEN (REGEXP_MATCH(Medium,”^(cpc|ppc|paidsearch)$”) AND Ad Distribution Network!=”Content”) THEN “Paid Search”
WHEN REGEXP_MATCH(Medium,” ^(cpv|cpa|cpp|content-text)$”) THEN “Other Advertising”
WHEN (REGEXP_MATCH(Medium,”^(display|cpm|banner)$”) OR Ad Distribution Network=”Content”) THEN “Display” ELSE “(Other)”
END
This will build your custom channel map for most standard data sources and mediums.
To add a custom channel, insert another WHEN clause like in this example below:
WHEN Source=”mysource” THEN “mysource”
WHEN Medium=”mymedium” THEN “mymedium”
You can also modify the channel mappings listed above; for example, maybe you call your email “Direct Mail” or you have a source of “Affiliate” instead of a medium.
Note that WHEN clauses are executed in order. Therefore, a session will map to the first WHEN clause seen.
A good way to implement a custom channel map in Google Data Studio is to look at your current custom data map and then copy the values over to this code.
For example, in the screenshot below I created a custom channel for traffic coming from my main domain to another site:
To build this in Data Studio, I would use the following code:
WHEN Source=”maindomain” THEN “Main Domain”
Which looks like this using the full code from above:
CASE
WHEN ((Source=”direct” AND Medium=”(not set)”) OR Medium=”(none)”) THEN “Direct”
WHEN Medium=”organic” THEN “Organic Search”
WHEN (Social Source Referral=”Yes” OR REGEXP_MATCH(Medium,”^(social|social-network|social-media|sm|social network|social media)$”)) THEN “Social”
WHEN Medium=”email” THEN “Email”
WHEN Medium=”affiliate” THEN “Affiliates”
WHEN Medium=”referral” THEN “Referral”
WHEN (REGEXP_MATCH(Medium,”^(cpc|ppc|paidsearch)$”) AND Ad Distribution Network!=”Content”) THEN “Paid Search”
WHEN REGEXP_MATCH(Medium,” ^(cpv|cpa|cpp|content-text)$”) THEN “Other Advertising”
WHEN (REGEXP_MATCH(Medium,”^(display|cpm|banner)$”) OR Ad Distribution Network=”Content”) THEN “Display”
WHEN Source=”maindomain” THEN “Main Domain”
ELSE “(Other)”
END
And it looks like this in Data Studio. First, the code:
Second, the data:
With this knowledge, you can easily create custom channel mappings to better display your or your client’s channels as you want to see them.