Google Analytics regex filtering: exclude except - regex

I'm quite new to regex and trying to do some Google Analytics filtering.
I have a website: www.domain.com (international version) and I have many country versions in subdirectories. e.g. www.domain.com/se
Now I want to create a filter to only show the international site. Therefore I have 15 (15 countries) exclude filters, which works ok, except for my "services" pages. The Swedish exclude, also filters out www.domain.com/services.
How can I exclude "/se" and "/se/" and "/se/*" without loosing my /services pages?

I'm not sure what google-analytics filters look like but if for france your filter looks like:
yoururl/fr
For sweden you could probably use:
yoururl/se(/|$)
Which says match /se followed by either a forward slash or end of input (/|$). You should probably add that to the end of all your filters to avoid excluding any other pages unintentionally e.g. yoururl/friendslist for the french example above.
See it on RegExr

Related

Regex to identify catgory pages but exclude products

I want to just see data for URLs which contain collection + category in google analytics so URLs which contain /collections/category example: https://baileynelson.com.au/collections/glasses
However i don't want to see data for products example: https://baileynelson.com.au/collections/glasses/products/adler
The regex i created is: ^/collections/(.*?)$ but it seems to be including product URLs.
Any ideas on how to create regex just so collection pages like https://baileynelson.com.au/collections/glasses, https://baileynelson.com.au/collections/sunglasses - but then product URLs are excluded?
Cheers!
Try using this regex here.
https:\/\/baileynelson\.com\.au\/collections\/[\w]+
The first part: htttps:\/\/baileynelson\.com\.au\/collections\/ This matches the domain and the path collections. The /s and .s are escaped.
Second part: [\w]+ This matches any words (abcde...z), and the + makes it so that is matches any amount.

Google Analytics Regex: Filter Landingpages with only one directoy

Basically I want to filter for pages in this format:
/page
but I don't want pages like this:
/dir/page/page
dir/page
Is there any way to accomplish this using the regex filter in Google Analytics?
I tried the following:
/*/ but its not working at all.
Try this (to match pages like /home):
^\/[0-9A-Za-z]+$
If you need to add other characters you can add it in the brackets (i.e. - and . to match pages like /home, /store.html or /page-path):
^\/[0-9A-Za-z\-\.]+$

Regex - analytics filter

I'm trying to filter some urls using gapi.client.analytics. What I want to achive is to create a regex filter that covers a lot of options. The regex should keep only urls that have this structure:
subdomain1.domain.com/some-post/
My problem is that I have some other urls that I don't know how to exclude, like:
subdomain1.domain.com/p/code/
subdomain1.domain.com/
subdomain1.domain.com/some-author/some-name/
subdomain2.domain.com/some-post/
subdomain2.domain.com/p/code/
I tried to use: ga:hostname=#subdomain1.domain.com to get links that contain only subdomain1.
I also tried: ga:hostname=~^[^/]+/?[^/]+/?$ to get only those who have 2 / in url.
Unfortunately I coudn't manage to do what I want.
Following regex should match URLs with exact one trailing directory
^[a-zA-Z0-9_-]+\.domain\.com\/[a-zA-Z0-9_-]+\/$
or
^[a-zA-Z0-9_\-\.]+\/[a-zA-Z0-9_-]+\/$
to match every domain.
You can text google analytics regex on analyticsmarket.com

Add one exclude filter for all language codes

I have website with many languages with address like
http://domain.com/<lang>/
I would like to create exclude filter in one of my views to report global traffic but i don't want to create dozen of exclude filter for each country (easy to forget to add some lang code).
Is this right to use custom exclude filter for Request URI with regex like ^\/[a-z]{2}\/ to exclude all requests which begins with /xx/ like /en/ /de/ etc.
Thanks for help.
You may use
^/[a-z]{2}(/|$)
There is no need escaping / in GA regex and (/|$) (match / or end of string) alternation group will make the / optional at the end of the input.

Google Analytics filters, only two countries

I want create a filter for include only two countries. For example United Kingdom and Russia.
I have two filters, first is excluding all countries. It is a filter where I set regex as pattern '.' and next filter is including only for this countries, pattern: United Kingdom|Russia.
But now I don't have any results displayed. Whats wrong with my regex?
Your regex is fine. You need to include the variable against which the regex filter is going to be executed. In your case, type Country (Pays in French)
Preview (Sorry for the French):
PS: I have tested it on my G account.
Edit:
As per your comment below, the . would only match one character (There are no countries with one character name). If you want to match all countries then your regex pattern would like .+ yet that leaves with this question: If you want to match all countries why use a filter in the first place?
If you set a filter to exclude all countries then there will be nothing in your reports, it does not matter what any other filters do because they cannot cancel each other out.
You simply need to place the include filter as it works as an "Include-only".
The RegEx you have already seems to be working on both filters, once again the problem is that your exclude filter is excluding everything.