> 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/variables/server-side-variables/public-function-scope/getfrontendvariable.md).

# getFrontendVariable

## `getFrontendVariable` Function

The `getFrontendVariable` function allows you to **access the value of a client-side variable from within a server-side variable** in JENTIS.

This is useful for reusing values already extracted on the client side (e.g., page URL, screen size, referrer) inside server-side logic for enrichment, condition handling, or persistence.

***

### Purpose

Use this function when:

* You want to **reference a client-side variable** in a **server-side context**
* The value has already been collected in the browser automatically by using this function
* You need that value for storage, enrichment, or decision-making server-side

***

### Function Definition

| Property          | Description                             |
| ----------------- | --------------------------------------- |
| **Function Name** | `this.getFrontendVariable`              |
| **Type**          | `function`                              |
| **Available In**  | Server-Side Variables                   |
| **Returns**       | `any` (type of the referenced variable) |

***

### Parameters

| Parameter     | Description                                     | Type     | Required                                      | Example               |
| ------------- | ----------------------------------------------- | -------- | --------------------------------------------- | --------------------- |
| `variable-id` | The **internal ID** of the client-side variable | `string` | <i class="fa-square-check">:square-check:</i> | `"document_ref_diff"` |

***

### Example Usage

```js
async function() {
  let referrer = this.getFrontendVariable("document_ref_diff");
  return referrer;
}
```

In this example, the server-side variable accesses the value of the client-side variable `document_ref_diff` (e.g., the referrer domain) and returns it.

***

### Use Cases

* Pass client-extracted values into server-side storage (e.g., store the referrer or screen size)
* Use client-side values for conditions inside a server-side tag
* Enrich server-side payloads with context from the browser

***

### Notes

* The referenced client-side variable must be **defined and resolved** during the same tracking event.
* Use the **internal variable ID** as shown in the JENTIS Tag Manager.
* The returned type depends on what the client-side variable returns — this can be a string, number, JSON, etc.

***

### Summary

`this.getFrontendVariable` bridges the gap between **client-side and server-side logic** in JENTIS. It allows you to leverage values already captured on the frontend in your backend processing—ensuring **data consistency**, **reusability**, and **simplified logic** across your tracking stack.


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.jentis.com/developer-guide/variables/server-side-variables/public-function-scope/getfrontendvariable.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
