# getFrontendVariable

### `getFrontendVariable` Function

The `getFrontendVariable` function is used to **retrieve the value of a client-side variable** or to **evaluate it on demand** during the execution of another variable.

#### Purpose

This function allows you to reference or reuse the value of another **client-side variable** by its **variable ID**, making your setup more modular and maintainable.

***

#### Function Signature

```ts
this.getFrontendVariable(variableId: string): any
```

#### Parameters

* **`variableId`** (`string`, required):\
  The ID of the client-side variable you want to retrieve.\
  This ID must match the **internal name** defined in the JENTIS Tag Manager.

***

#### Return Value

* **Type:** `any`\
  Returns the value of the specified client-side variable.\
  The returned type depends on the definition of the referenced variable.

***

#### Example

**Retrieve the value of another client-side variable**

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

In this example, the value of the `document_ref_diff` variable is retrieved and returned from within another client-side variable.

***

#### Use Cases

* Compose variables by combining values from other client-side variables.
* Avoid duplicating logic across multiple variables.
* Maintain a centralized and DRY (Don't Repeat Yourself) configuration.

This function is essential when building dynamic tracking setups that depend on multiple contextual inputs from the browser.


---

# Agent Instructions: 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/variables/client-side-variables/public-function-scope/getfrontendvariable.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.
