1
votes

I created a Google Data Studio dashboard with Google Analytics as data source. As I'd like to show the user engagement of the website by different country site, I created a new dimension filter (country site) with following codes:

CASE   
WHEN REGEXP_MATCH(Page, "((?i).*/uk/).*") THEN "UK"  
WHEN REGEXP_MATCH(Page, "((?i).*/us/).*") THEN "US"  
ELSE "Other"   
END

However, I found the number of users without any filter is less than that with "UK" filter applied, which I think there should be something wrong.

Would somebody has any idea?

2

2 Answers

0
votes

I'm no regex expert but I think you need to escape the '/'s

CASE   
WHEN REGEXP_MATCH(Page, "((?i).*\/uk\/).*") THEN "UK"  
WHEN REGEXP_MATCH(Page, "((?i).*\/us\/).*") THEN "US"  
ELSE "Other"   
END
0
votes

Becky, I think your regex is too complicated (and you do need to escape the slashes as Bobbylank says).

I have a similar thing (working fine) in my reports, and my code looks like this:

WHEN REGEXP_MATCH(Source, "^.*mymatchstring.*") THEN "mymatchstring"

Have a try at this:

CASE   
WHEN REGEXP_MATCH(Page, "^.*\/uk\/.*") THEN "UK"  
WHEN REGEXP_MATCH(Page, "^.*\/us\/.*") THEN "US"  
ELSE "Other"   
END