Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Tag Manager Server Side Custom Client Regex Problem

I am currently trying to develop a custom client template for the Google Tag Manager Server Side and would like to react to a certain URL pattern. Unfortunately, I'm either being silly with the regex or there is somehow a problem with the sandbox JS. I have simplified the example. There is a problem with the backslash at the beginning. Here is the code and the error message. Does anyone have an idea?

const claimRequest = require('claimRequest');

let text = "/abc";
let pattern = /\/ab[c]/;
let result = pattern.test(text);

claimRequest();

And the error message:

1 Error(s) parsing the input:
token recognition error at: '\'
Offending token '' at 4,15.
like image 271
lstrauch Avatar asked Oct 15 '25 04:10

lstrauch


1 Answers

It appears that as this is a sandboxed limited capabilities javascript environment where RegExp constructor have not been included, hence i am also unable to perform this basic and very common task of splitting templates per country let's say. Quite a big limitation in my opinion. Here is the full list of supported js in custom templates and RegExp isn't there. Hope they'll add it in the future: https://developers.google.com/tag-platform/tag-manager/templates/standard-library

like image 56
Yuliyan Yordanov Avatar answered Oct 17 '25 21:10

Yuliyan Yordanov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!