Filter sensitive URL query parameters before a tag receives the URL.
Transformation functions modify a value before a tag uses it. This lets you remove, mask, standardize, or hash data at the tag level.
This guide creates a function that filters URL query parameters. It masks values containing @ and values for the gclid parameter.
How transformation functions work
A transformation function runs when its associated tag runs. The tag passes a value into the function. The function returns the transformed value for the tag to use.
Functions accept one input value and must return one value. When several inputs are added in a tag, JENTIS concatenates them into one parameter. See Function Creation Process for details.
JENTIS provides out of the box functions for common data transformations, including hashing, trimming, lowercasing, anonymization, and pseudonymization. You can also create custom functions.
Common use cases
Privacy controls: Mask or hash identifiers before a tag receives them.
Consistent formatting: Trim whitespace, normalize letter case, or format dates.
Custom logic: Build values, apply conditions, or filter unwanted data.
Create a URL filter function
This example masks selected query parameter values. It preserves the URL origin, path, and fragment.
Go to JENTIS Tag Manager → Functions.
Create a new transformation function.
Paste the following code.
Update REMOVE_VALUES to mask values containing specific strings. Update REMOVE_PARAS to mask values for specific parameter names.
Apply the function to a tag
Add the function to the URL value in the relevant tag configuration. Pass a variable that contains a complete URL.
Test the tag in Preview before publishing. Confirm that intended parameters are masked and required parameters remain unchanged.
function(input){
var final_output = input;
var REMOVE_VALUES = ["@"]; // Mask values containing an item in this list
var REMOVE_PARAS = ["gclid"]; // Mask values when the parameter name matches
try{
var in_url = new URL(input);
var params_output = [];
for(const [key, value] of in_url.searchParams.entries()) { // Each entry is a [key, value] tuple
var ret_key = key;
var ret_val = value;
console.log("scanning key/value: "+key+value)
// Mask values on match
REMOVE_VALUES.forEach(filterItem => {
if(value.indexOf(filterItem) >= 0)
ret_val = "value_masked";
});
REMOVE_PARAS.forEach(filterItem => {
if(key == filterItem)
ret_val = "value_masked";
});
params_output.push(ret_key+"="+ret_val);
}
final_output = in_url.origin+in_url.pathname+"?"+params_output.join("&")+in_url.hash;
}catch(e){
console.log(e);
}
return final_output;
}