Google Analytics Regex to exclude certain parameter - regex

I'm relatively new to regex and in order to set up a goal in Google Analytics, I'd like to use a regular expression to match a URL containing both "thank-you" and "purchaseisFree=False" but exclude two specific rate plans that are represented in the URL as "productRatePlanID=5197e" and "productRatePlanID=c1760".
Here is a full URL example:
https://www.examplepage.com/thank-you?productRatePlanId=5197e&purchaseIsFree=False&grossTotal=99.95&netTotal=99.95&couponCode=&invoiceNumber=INV00000589
I tried using this post as a model and created this regex:
\bthank-you\b.+\purchaseIsFree=False\b(?:$|=[^c1760]|[^5197e])
However, I'm not getting the desired results. Thanks in advance for any suggestions.

I think the below mentioned regex should solve your problem. It uses the positive|negative look ahead facility. We can sit at the beginning of http[s] and check all the three condition and then engulp the whole tree
(https?:\/\/)(?=.*?productRatePlanId=(?!5197e&)(?!c1760&))(?=.*?thank-you)(?=.*?purchaseisFree=False).*
Note:- I have used & after the productRatePlanId values just to ensure it doesnt ignore other values as 5197f, 5198d and all other sorts of values.

Related

I only want Regex to only search spelling mistakes - how to exclude correct spellings?

My goal is to identify a words/phrases which has been misspelt.
I want to exclude correct instances from my search. The word I want to identify all misspellings of is "Whats'App" (with and without the apostrophe).
I want to identify instances when a letter has been swapped out for a number.
Here is my regex now which works well for all instances including correct spellings. I want the code to exclude the following two words; whatsapp and whats'app.
I am running this in Elastic.
wh[a4]t[s5]’?[a4]pp
Thank you all for your help. The solution to this question was to exclude the correct instances by using #&~(abc.+). I discovered the answer on eslatics site.
Here is the query that now works;
wh[a4]t[s5]’?[a4]p+#&~(whats’?ap+)
Unfortunately, I have some unexpected results where some misspellings are not identified. It must relate to a different problem in this query that I will post as a separate question.
Thanks,
Sean

Using Regex in Google Analytics Filter Out URLs that contain one string and does not contain another

You will find this simple and silly Question but it is not. Please Guys help me here.
I have set of URLs in these two formats:-
https://lenskart.sg/collections/abc/products/xyz
https://lenskart.sg/collections/abc/xyz
I only need those URLs that contain the word "collections"(double quote to highlight the word) and does not contain the word "products"
How to write regex(Regular Expression) for this?
PS:- I need To filter out the URLs from Google Analytics using Regex. The Best expression I have come up till now is:- (collections/)(\w+)(/)(?!products) But Google Analytics is showing it as an Invalid Regex. It is working fine in other regex testing tool. May be Google Analytics is not accepting Negative Lookaheads. Here are Few URLs to support the same:- Google Analytics Regex - Alternative to no negative lookahead
https://www.reddit.com/r/analytics/comments/5v6q4i/regex_expression_for_does_not_contain/
https://recalll.co/?q=negative%20lookahead%20-%20Google%20Analytics%20look%20ahead&type=code
Please Guys help me here. It's a big issue for me
I do not think you need a complex regular expression at all, an include and subsequent exclude filter should suffice.
Do an include filter, select request url als filter field and "/collections/" as filter pattern. This will dismiss all Urls that do not have "/collections/" in their path (or to put it another way, this will only include Urls that match the pattern).
Then (order is important) do and exclude filter, select request url as filter field, and enter "/products" as pattern.
Filters are applied in the order they are displayed in the view settings. Each subsequent filter will work on the data a previous filter has returned. So it is often easier to split the work between multiple filters.
This is assuming that you are filtering in your view settings, but frankly if this is a filter in a report, it basically works the same way (you have to click the "advanced" link next to the filter box to access multiple filter conditions, and "Request Url" is called "Page" here, but otherwise it's basically the same).
Filters in reports do not support negative lookaheads, the (permanent) view filters allegedly do.
^\/lenskart\.sg\/collections\/abc((?!\/products).)*$
I'm not an expert, but the above RegEx will satisfy the following by matching on the first and third URLs, but not the middle.
/lenskart.sg/collections/abc/
/lenskart.sg/collections/abc/products/xyz
/lenskart.sg/collections/abc/services

Regex for Google Analytics Goal

I've searched all the other Regex on Google Analytics questions but I can't use the answers as this is pretty specific to my problem.
I want to set a destination URL goal but use Regex to flag it as a goal IF string includes /general/
I basically want to track everyone in GA who goes to a Vehicle Detail Page but /general/ brings them to a Search Results Page.
so in other words
/used-cars/general is not correct
/used-cars/citreon/ is correct
/used-cars/TOYOTA/ is correct
Basically, any other car maker is correct after /used-cars/ regardless if it is capitalized or not.
Thanks in advance, everyone.
Your regex is on the right path, but you should escape any special characters. Try the below instead:
/used\-cars/(citreon|TOYOTA|RENAULT|VOLKSWAGEN|VAUXHALL|HONDA|BMW|NISSAN|PEUGEOT|DS|FORD|HYUNDAI|INFINITI|MERCEDES\-BENZ|MITSUBISHI)/

Grabbing specific query string parameters from URL with regex

We have an implementation of Liferay portal and I'm just getting started with using Google Analytics with it. I'm noticing a lot of duplicate entries in GA, mainly because of the query strings in the URI, for example:
/web/home-community/search-and-help?p_p_id=mytcdirectory_WAR_mytcdirectory&p_p_lifecycle=1&p_p_state=normal&p_p_mode=view&p_p_col_id=column-3&p_p_col_count=4&_mytcdirectory_WAR_mytcdirectory_action=getResults
I'm playing around with the Search and Replace filters in GA (using regex) and my goal is to try to pull out the ?p_p_id and &*_action parameters from the URI, and disregard the rest. I'm getting close with the following regex:
^([^\?]+)([\?\&]p_p_id=[^\&]+)?.*(\&[^\&]+_action=[^\&]+)?.*$
But that last grouping isn't working correctly. If I remove the ? from the end of the last grouping it matches, but the problem with that approach is that not all URIs contain that query string so it needs to be optional. But if I keep it in, it won't grab that last parameter. My regex fiddle is located here:
http://regex101.com/r/qQ2dE4/13
Thank you all in advance for any help.

Regex: Match any string but one ending with thanks/

I am attempting to set up a goal funnel in Google Analytics. It is for an online quote request system that we want to track. Basically all the pages that contain the quote request form have unique dynamically generated urls that are similar. The form of the URL is:
/quoterequest/categoryone/categorytwo/productname/
I have regex that works for tracking that:
^/quoterequest/([A-Za-z0-9/-]+)?
Today we added a thank you page after the user submits the form. The URL is always the same for that:
/quoterequest/thanks/
I would like to modify the above regex so that it continues to match any of the Quote Request URLs, but NOT that thank you URL. I have been trying different variations, including t. he negative look ahead,but unfortunately I am not very experienced with regex and I think I've been doing it completely incorrectly. Can anyone give me some insight as to the correct method of doing this?
You can use:
^\/quoterequest\/(?!thanks\/?$)(?:([A-Za-z0-9\-]+)\/?)*$
See it