Schaeffer Warnock
Schaeffer Warnock

Reputation: 309

How to exclude specific URL path with Regex (Google Analytics)?

I am looking for some assistance on excluding numbers at the end of a URL. I am setting up a Google Analytics goal that allows me to see order confirmations based on a URL string, however, I need to exclude the number 0 and -1. For example, the destination url is for an order would be test.com/checkout/confirmation/123456 with 123456 being the order number (which are always 3 or more digits). We currently have our URL structure setup so that if a customer signs up it would take them to test.com/checkout/confirmation/0 or test.com/checkout/confirmation/-1 which is not what we want to track. We only want to track order numbers at the end of the URL so it gives us the correct checkout information and not signup information. Is there a way of excluding both 0 and -1 from the end of our URL with regex so it only captures order IDs?

Currently I have the regex setup to /checkout/confirmation/ but it is pulling all of the order numbers and the signup confirmations...

Screenshot of Google Analytics Goal Setup

Upvotes: 0

Views: 1708

Answers (2)

jjul
jjul

Reputation: 36

The first answer is on track but there are some additional characters that you will need to include to get the correct regex in GA. I have tweaked @nyuen's answer:

\/checkout\/confirmation\/[0-9]{3,}

Upvotes: 1

nyuen
nyuen

Reputation: 8907

This is one option:

/checkout/confirmation/[0-9]{3,}

This matches order IDs that are at least 3 digits long.

Upvotes: 1

Related Questions