Data Studio
3.7K members online now
3.7K members online now
Ask questions about Data Studio
Guide Me
star_border
Reply

Substring as custom dimension

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

I've been trying to make a substring of a preexisting dimension its own dimension and am running into some trouble. The url's of article pages on my site look like this 

www.mysite.com/articles/article_name

or this

www.mysite.com/articles/article_name?source_info

I'm trying to create a custom dimension that groups any two urls with the same article name together so that I can evaluate the performance of each article page and ignore the source. I've tried to create a custom dimension with the following formula:

CASE WHEN REGEXP_MATCH(Landing Page, '.*\?.*') THEN REGEXP_EXTRACT(Landing Page, '/^[^\?]*/') ELSE Landing Page  END

I'm new to regular expressions, but I essentially want to identify urls with a '?' and take a substring of those urls that includes all characters before the '?'. This function returns an error. Any thoughts? I'm thinking it has something to do with the regular expressions. Thanks!