문제

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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top