Consolidate source data in Google Data Studio

Business Benefits

Visualize improved and useful source data.

If you want the dimension to be available throughout the dataset, in the main menu, go to Resource > Manage added data sources > Edit > + Add a Field.

If you need the dimension only at the table or graph level, click + Create New Field at the end of the Fields picker, or, in the selected dimension area, click + Add dimension.

In this case, we recommend building a new dimension at a data-source level.

Use the function CASE and regular expressions to group all Facebook and (if needed) Instagram sources into one.

WHEN REGEXP_MATCH(Source, '.facebook.') THEN ''
WHEN REGEXP_MATCH(Source, '.instagram.') THEN ''

For Facebook, you can create a unique source name to group all variations tracked by Google Analytics as a custom dimension.

If you’re creating a visualization that displays only source data (not medium), you can separate Google data into organic and paid traffic:

CASEWHEN REGEXP_MATCH(Source, '.facebook.') THEN 'facebook'WHEN REGEXP_MATCH(Source, '.instagram.') THEN 'instagram'WHEN Source = '' THEN 'twitter'WHEN Source = 'google' AND Medium = 'cpc' THEN 'google ads'WHEN Source = 'google' AND Medium = 'organic' THEN 'google organic'ELSE SourceEND

Enter your case function in the formula box and save.

1 Like