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

Creating a new dimension with REGEXP_EXTRACT not working...

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hey,

 

I have a Google Analytics Event that outputs something like;

 

Event Category: "Ecommerce"

Event Action: "Product Selected"

Event Label: "[Product Name] [Product Colour] [Product Size]"

 

E.g. [Fruit of the Loom Sleeveless T-Shirt] [Pink] [Extra Small]

 

If I understand what I've read so far, I can use REGEXP_EXTRACT to split that into 3 dimensions.

 

I'd use something like

 

^\[([A-Za-z\s]+).*$
 ^\[[A-Za-z\s]+\]\s\[([A-Za-z\s]+)\]\s.*$
 ^.*\[([A-Za-z\s]+)\]$

 

To extract fields 1, 2 and 3 but I'm getting errors using the above. In fact, errors I can't see - all I get is a red line appearing below the dimension - if I inspect element, there's some error text which is hidden.  

 

Any ideas about how to do this properly?

Re: Creating a new dimension with REGEXP_EXTRACT not working...

Visitor ✭ ✭ ✭
# 2
Visitor ✭ ✭ ✭
I had to double escape the characters.

REGEXP_EXTRACT(Event Label, '^\\[.*\\]\\s\\[(.*)\\]\\s\\[')

But it's very slow.