Regex for conversion matching not working correctly?

Hi,

I’ve been trying to count conversions with matomo when an URL with a certain URL pattern has been visited. The URL looks like this:

http://domain/keyword/keyword/1/2408

The regex we’ve created is this: domain/[^/]/[^/]/1/ which is correct according to regex101: build, test, and debug regex

But when using this regex in Matomo for conversion tracking, nothing happens.

Is there somethign wrong with matomo or could help me with a regex that works with matomo, please?

Best,

Paul

Hi Paul,

has this resolved for you? I have the same problem but think it might be a broader phenomenon, so I created another issue. If you are interested:

Best
vanye

Did you try

domain\/.*\/.*\/1\/.*

You mean for segmentation? For segmentation I use the Matomo standard function. Here are two screenshots to make it clearer. (As a new user I can only embed on per answer. so I’ll put the second one in a new answer).

The inclusion (“Equals”) works, the exclusion (“Not Equals”) does not work.

Both use the same IPs and what I would like to do here is create one segment for internal visitors (from internal IP) and one segment for external visitors (not from internal IP).

2 things about your reply…

  1. if you do my_var ≠ 'A' OR my_var ≠ 'B' then it will be always true…
  2. The subject was not about segments but about conversion tracking. Don’t forget that segments are not filter. If a user goes to page A and to page B, you’ll see his navigation to page A and B even if you segment on page A…

(note also that you can edit our post :wink:)

Sorry if I am slow to understand …

So you are saying that the negative segmentation does not work because of the OR condition? Should I use the AND condition to exclude three different IPs for one segment?

The other part of my post was about conversion tracking. I thought it was strange that all my goals that exclude conditions do not work so I made a connection to the negative segmentation that did not work.

This is just a boolean problem. With the following rule:

my_var ≠ 'A' OR my_var ≠ 'B'

Means « I’ll see the data if my_var is not A or if it is not B »
case my_var='C' :arrow_right: :white_check_mark: as it is different from ‘A’, you’ll be able to see this data in your segment
case my_var='A' :arrow_right: :x: as it is different from ‘B’ (the second condition), you’ll see also this data in your segment whereas I think you wouldn’t…
So use and AND instead of an OR.

Goals are defined with some very simple rules… (maybe too simple?)
But most of the time, you should achieve a goal when you access some pages (more rarely when you don’t access some page). the page pattern is not a regex but a pattern:
image

Another way to achieve a goal could be use HTTP API (params idgoal and revenue) or JavaScript API (command trackGoal( idGoal, [customRevenue]);) or MTM (Tag of type Matomo Analytics, Tracking type = Goal)

Thank you for your time and effort, Philippe. I have altered the segmentation to AND and it works now :smile: I hope I am not taking advantage if I keep asking about the goals …

Concerning the goal: The site has an internal search and offers additional filters. So, if I search for “software”, the resulting URL is
https://domain/dataset/?q=software

If I need additional filters, these are added to the URL, separated by &. So, if I filter the search e.g. with the tag “Masterportal”, the resulting URL is
https://domain/dataset/?q=software&tags=Masterportal

If I want to define the number of searches conducted as a goal and do it with regex, the resulting goal could be
?q=(\d|\D)+$
I have actually implemented this one and it works.

However, this goal would also count the filters as new searches. So, if I want to exclude the filters from the count of searches, the goal should look like
?q=[^&]+$
Meaning, if the URL contains a &, it shall not be counted as a search. But it does not work. I have checked the regex with https://regexr.com/ and it seems functional

I think the actual options to configure goals won’t allow you to do such thing…
I think you should use JavaScript or MTM config to detect such goal…

Ah, that’s what I thought. Thank you for all the information!

Just in case anyone else is interested, here’s the solution I’ve implemented as a goal. Since negative conditions (exclusions) are not allowed, I defined the allowed characters. This one is for German (if you think the umlauts are strange) and so you might want to adjust if you use it for other languages. Just don’t forget the space.

.*\?q\=[A-Za-z0-9äÄöÖüÜß%:;,./+\- \\]+$

1 Like