1

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 Answers 2

0

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
1
  • 1
    Thanks for it! @Bobbylank I just tried your codes in data studio but it still doesn't work... I am not sure what's wrong with the codes/ filter....
    – Becky
    Apr 27, 2018 at 10:57
0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.