regexclientgoogle-tag-managergoogle-tag-manager-server-side

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.

Solution

  • 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