Trigger Condition : Possible to call a Variable (Constant) containing a Regex?


I’ve been trying to set up something in a MTM project, I’m not sure it’s possible ;
Here is the deal :

I need to use a Regex as a condition to execute a Trigger.
As I need the same Regex in all my triggers (quite a few), and as this Regex is likely to be modified quite often, I tried to record the content of the Regex in a Constant Variable, and to call this Variable in the trigger condition…

But so far, it doesn’t seem to work.

Anyone tried something similar ?
Can someone tell me if it’s feasible ? or if it is a current limit in MTM ?

Thanks a lot

best rgds



I think the solution is use a JavaScript function variable:

That will execute your Regex and return 0 or 1…
Here an example to use a datalayer variables (userID and env in my case) in the JavaScript function variable:

function () {
	if(MatomoTagManager.dataLayer.values.userId && MatomoTagManager.dataLayer.values.env) {
		return MatomoTagManager.dataLayer.values.userId + '-' + MatomoTagManager.dataLayer.values.env
	return "";
1 Like

Hi Philippe !

Genius ! :index_pointing_at_the_viewer:

That tip unlocked my situation !
Of course, it’s rather more difficult than what it could have been if we could write a Regex in a Constant Variable and just call it in the Trigger condition…
Maybe in the future.

Thanks a lot for your help

Best rgds