> 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/developer-guide/filter-variable-in-tags.md).

# Filter Variable in Tags

In JENTIS, e-commerce and list-related tags include a powerful feature called the **Filter Variable**. This allows you to restrict tag execution to only specific data elements—typically **products**—based on a defined property value.

### What Is the Filter Variable?

The Filter Variable is found in the configuration panel of a tag (e.g., Google Analytics 4 `view_cart` tag). It is typically set to evaluate the `type` property of product objects in the JENTIS Data Layer.

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

With this setting, you can **filter which product objects are passed to the tag**, ensuring that only those relevant to the tag's context are included.

### Background: JENTIS Data Layer Behavior

Some interactions—like `cartview`, `checkout`, or `productlist`—may involve multiple product objects within the same page load. These are all pushed into the same state and would, by default, be visible to all tags triggered in that state.

To avoid submitting irrelevant data, the Filter Variable helps you isolate only the required product entries.

### Example: Mixed Product Contexts

The following example pushes two products with different `type` values:

```javascript
_jts.push({
  track: "product",
  type: "cartview",
  id: "123",
  name: "Baby Oil"
});

_jts.push({ track: "cartview" });

_jts.push({
  track: "product",
  type: "productlist",
  id: "456",
  name: "Baby Shampoo"
});

_jts.push({
  track: "productlist",
  listname: "related_products"
});

_jts.push({ track: "submit" });
```

In this case:

* `Baby Oil` is part of a `cartview`
* `Baby Shampoo` is part of a `productlist`

### Applying the Filter

Let’s say you configure a GA4 `view_cart` tag. You only want to send products with `type: "cartview"`.

By setting the Filter Variable to evaluate the `type` property and match it to `cartview`, only the product "Baby Oil" will be included.

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

This ensures:

* Clean data in your tag
* Avoidance of unrelated products being submitted
* Higher tracking accuracy for interaction-specific tags

### Summary

* Use the **Filter Variable** to narrow tag input to relevant product types.
* This is especially useful when multiple product contexts are present on a single page.
* Always align the filter value with the `type` of product object your tag is designed to handle.

For more on how product types work, see the [E-Commerce Tracking](/data-capture/web-tracking-setup/set-up-jentis-data-layer/e-commerce-tracking.md).


---

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

```
GET https://docs.jentis.com/developer-guide/filter-variable-in-tags.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
