Analytics
4.7K members online now
4.7K members online now
Learn how to set up goals and Ecommerce tracking, verify accuracy of attribution traffic sources, and discuss funnel visualization, Multi-Channel Funnels, the Goal Flow Report, and Enhanced Ecommerce
 
Guide Me
star_border
Reply

Destination URL Using Regex Works on one goal but not another?

Follower ✭ ✭ ☆
# 1
Follower ✭ ✭ ☆

I'd imagine I've missed a step somewhere, but would love some help.

 

I have 2 goals:

 

1. Destination URL - I want to track completions here: https://www.domain.com/thank-you

 

I set up a destination URL goal with a regular expression: .*\/thank-you 

 

This works fine.

 

2. Destination URL - I want to track completions here: https://www.domain.com/dire/dire/subscribe/sub_good

 

I set up a destination URL goal with a regular expression: .*\/sub_good

 

 

It won't fire (using real time reports where I can see the 1st thank you page firing. I've tried:

 

.*\/sub\_good (not even sure if I have to escape the _)

.*\/dire/dire/subscribe/sub_good (do I need to escape all back slashes)

 

2 Expert replyverified_user
1 ACCEPTED SOLUTION

Accepted Solutions
Marked as Best Answer.
Solution
Accepted by topic author Help P
November 2015

Re: Destination URL Using Regex Works on one goal but not another?

Top Contributor
# 2
Top Contributor
Hi,

^/thank-you$
^/dire/dire/subscribe/sub_good$

should do the job. You don't need any .* at the start or at the end of a regular expression. You have to escape (\) characters only if they have special meanings in a regex, like dot \. or question mark \?.

You may always try any new regex in advance using the filter field above your Behavior > Site Content > All Pages report - it accepts regexs.

Christoph

View solution in original post

Marked as Best Answer.
Solution
Accepted by topic author Help P
November 2015

Re: Destination URL Using Regex Works on one goal but not another?

Top Contributor
# 2
Top Contributor
Hi,

^/thank-you$
^/dire/dire/subscribe/sub_good$

should do the job. You don't need any .* at the start or at the end of a regular expression. You have to escape (\) characters only if they have special meanings in a regex, like dot \. or question mark \?.

You may always try any new regex in advance using the filter field above your Behavior > Site Content > All Pages report - it accepts regexs.

Christoph

Re: Destination URL Using Regex Works on one goal but not another?

Top Contributor
# 3
Top Contributor
Technically, all you need is
thank-you$
sub_good$
VP & Chief Evangelist at Hub'Scan | Contact me
Level 80 Digital Analytics Warrior, KPI Therapist and Keeper of the One True Tagging Plan

Re: Destination URL Using Regex Works on one goal but not another?

Follower ✭ ☆ ☆
# 4
Follower ✭ ☆ ☆
Or, if you expect additional characters after the thank you, all you need is:

thank-you

Yes?

Re: Destination URL Using Regex Works on one goal but not another?

Top Contributor
# 5
Top Contributor
Correct
VP & Chief Evangelist at Hub'Scan | Contact me
Level 80 Digital Analytics Warrior, KPI Therapist and Keeper of the One True Tagging Plan

Re: Destination URL Using Regex Works on one goal but not another?

Follower ✭ ☆ ☆
# 6
Follower ✭ ☆ ☆
You'd be amazed at how many people feel you need that .*/ or ^/ in front of the thank-you. Also, why would you even want to specify the terminating $ ? What happens if this gets truncated with URL params - you're cooked!

Re: Destination URL Using Regex Works on one goal but not another?

Top Contributor
# 7
Top Contributor
Hi Marlon,

the terminating '$' is to be used quite often - it happens a lot that for example an URL of a contact form is /somepath/contact/ and the thank-you page in the next step is /somepath/contact/thankyou.html or similar. There you need the '$' to distinguish them in the regex.

The '^' at the start only sometimes is necessary.

However, it' always a good coding attitude to restrict your regex to the most specific form that fulfills your requirements, even if it's not the shortest possible.

The '.*' (zero or more occurrences of a character) you only need in the middle of an expression, and even then it's often more specific to use '.+' (one or more occurrences of a character) instead.

Christoph