> For the complete documentation index, see [llms.txt](https://docs.jentis.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.jentis.com/use-cases-and-tutorials/transformation-functions-url-parameter-filtering.md).

# Transformation Functions - URL Parameter Filtering

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](/jentis-dcp-elements/functions-transformations/function-creation-process.md) 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.

<figure><img src="/files/g75biMlJDRP2w5IOJh8g" alt=""><figcaption></figcaption></figure>

### 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.

1. Go to **JENTIS Tag Manager → Functions**.
2. Create a new transformation function.
3. Paste the following code.

Update `REMOVE_VALUES` to mask values containing specific strings. Update `REMOVE_PARAS` to mask values for specific parameter names.

```javascript
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;
} 
```

### 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.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.jentis.com/use-cases-and-tutorials/transformation-functions-url-parameter-filtering.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
