AdWords is now Google Ads. Our new name reflects the full range of advertising options we offer across Search, Display, YouTube, and more. Learn more

Data Studio
2K members online now
2K members online now
Ask questions about Data Studio
Guide Me

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

or this

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!