Analytics Log - Adil Khan

View Original

Data Studio - How To Group Content Where Pattern Equals 'Page Starts With' Using CASE + REGEX_MATCH

Let’s say you want to group content [page paths] based on the opening text pattern. Example:

IF page path starts with /news, THEN output should be “News”

IF page path starts with /blog/news THEN output should be “Blog”

Else “Other”

You can use REGEX_MATCH to find text pattern and combine it with CASE (IF THIS THEN THAT).

In Regex, you can use the caret (^) symbol to instruct regex that the variable value should start with X. The extra chars in the below markdown take care of casing in the text, so you don’t have to worry about it.

See this content in the original post

and now, let’s just test this in Data Studio.

Yep, works!