I tried to create event rule for click tracking of "a" tag which has specific property, but the rule fired even on all other links.
I investigated it and found SL.propertiesMatch function has a procedure might cause unintended behavior easily.
I intend to assign propery "data-tracking" with any value at "condition" area in DTM and set "data-tracking" = .* (RegExp).
Then I clarified it on staging website, every time i clicked anchor links, that rule fired.
When links which does NOT have specified property are clicked, DTM searches "data-tracking" property and returns null.
Then it checks if null(null) matches /.*/i (RegExp). It must be failed, but it returns TRUE because RegExp.test() method treats passed null as a string "null"!!
SL.propertiesMatch = function(e, t) { if (e) for (var n in e) if (e.hasOwnProperty(n)) { var i = e[n] , a = SL.getElementProperty(t, n); if ("string" == typeof i && i !== a) return !1; if (i instanceof RegExp && !i.test(a)) return !1 } return !0 }
Solved! Go to Solution.
Hi Kunihiro ,
One of the work around for the problem would be to create Negative look-ahead regular expression like ^((?!null).)*$ (RegEx) such that "null" values are rejected however the only thing to remember is that this expression would also reject the value "null-xcxcxc" .
Also, Generally it is recommended to check whether a string is null or not before passing it to regex test function Hence I would suggest to write a custom rule condition for your use case like below to avoid missing out on any cases
Thanks & Regards
Parit Mittal
Hi Kunihiro ,
One of the work around for the problem would be to create Negative look-ahead regular expression like ^((?!null).)*$ (RegEx) such that "null" values are rejected however the only thing to remember is that this expression would also reject the value "null-xcxcxc" .
Also, Generally it is recommended to check whether a string is null or not before passing it to regex test function Hence I would suggest to write a custom rule condition for your use case like below to avoid missing out on any cases
Thanks & Regards
Parit Mittal
Hi,
Is the above issue resolved ?. If yes, yo can go ahead and mark the above answer as correct.
Thanks & Regards
Parit Mittal
Views
Replies
Total Likes
I set "a[data-tracking]" to as a workaround.
I think your workaround also works well but it's a little bit more complicated than css selector.
It'd be helpful if this fix is applied.
Best regards,
Kunihiro Sasaki
Views
Replies
Total Likes
Views
Likes
Replies