1
votes

I am setting up a conversion funnel in Google Analytics and want to capture all product collection pages for my Shopify store. To do this, I want to match everything with this pattern: ^/collections/.* but I also need to exclude everything with this pattern:

^/collections/.*/products/.*

The reason being that collection(product category) pages follow this structure: /collections/[collection-name]

E.g.,

  • /collections/shoes
  • /collections/tshirts
  • /collections/hats etc

Product pages follow this structure: /collections/[collection-name]/products/[product-name]

E.g.,

  • /collections/shoes/products/pink-reeboks
  • /collections/tshirts/products/plain-white-tee

So I want to capture just the collection pages but not the product pages.

I have already identified a negative lookahead as the ideal way to do this. However, Google Analytics does not allow negative lookaheads, so I need another way to do this. Any help would be greatly appreciated!

Thanks in advance.

1
Couldn't you do ^/collections/collection-\d$Blexy
Hi Blexy. That won't work because the collections are all named collection-1 collection-2. I was just using those as examples. It's more like shoes, hats, tshirts, pants, etc. I've changed the question to clarify that.Gabe

1 Answers

1
votes

If you use ranges [a-zA-Z0-9] this won't match a \. See Rubular for a simple demo of this regex.

^/collections/[a-zA-Z0-9]*$

Of course you need to update your regex if you use collection tags within Shopify.