Analytics
5.3K members online now
Understand information in your reports and troubleshoot reporting issues such as self-referrals, (not set) data, and inaccurate information
 
Guide Me
star_border
Reply

How do I track one word in URL as a goal using Regex?

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭
 

Example:

  1. /product/blackjacket
  2. /product/redjacket

I want o track every URL as one goal mentioning word jacket.

What regex should I write?

1 Expert replyverified_user
Marked as Best Answer.
Solution
Accepted by topic author Ivan M
February 2017

How do I track one word in URL as a goal using Regex?

Top Contributor
# 2
Top Contributor

Hi,

 

Just choose Regular expression and put jacket into the field in the goal settings, any URL containing jacket will trigger the goal.

Remember that a goal is counted only once in a session, so if a user visits multiple pages with a URL containing jacket, only a single goal will be recorded. Hope this helps, let me know if you have questions.


Arnold Majlath, Google Analytics Top Contributor
Circle Me On Google+ | Visit me @ Redfly Digital

Re: How do I track one word in URL as a goal using Regex?

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭

Arnold's suggestion is simplest--and thus probably best--as long as you don't have any URLs like /post/bluejacket or /all-jackets/orange you don't want to capture.

 

If you only want to capture jacket URLs that are under the /product directory then something like this will work:

\/product\/.*jacket.*

 

That will track URLs with these paths:

  • /product/blackjacket
  • /product/redjacket
  • /product/jacket-blue

But not these:

  • /post/bluejacket
  • /all-jackets/orange