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