# String Substitution

Many text fields and rules in GMetri support substitution out of the box.

## What is String substitution? <a href="#using-variables-through-text-substitution" id="using-variables-through-text-substitution"></a>

Let's say you have Text element, and you want to show the user his/her score, or a value that you captured earlier. How can  you do that?

By adding the following in the text element:

```
Hi {{firstname_var}}!

Your current score is {{score}}
```

and the values in the text element will get replace with the corresponding variables.

{% hint style="info" %}
To prevent escaping of special characters, you can use triple curly brackets `{{{variable_name}}} (Case Sensitive)`
{% endhint %}

## What are the values that I can substitute?

Apart from [Variables](/metaverse/build/variables.md#custom-variables), [Variables](/metaverse/build/variables.md#global-variables) and [Variables](/metaverse/build/variables.md#autogenerated-variables), there are a few additional things available to you that you can substitute. These are:

* `viewer_token`: The token used to authenticate the viewer
* `session_uuid`: The unique identifier for this session. Unique for every page load.
* `organization_slug`: The identifier for the current workspace
* `deployment_slug`: The identifier for the current deployment
* `scene_id`: Contains the current scene id
* `deployment_url`: The URL that the viewer uses to access this experience

## Example <a href="#using-variables-through-text-substitution" id="using-variables-through-text-substitution"></a>

You can use variables in text elements through substitution​.

Let's say you have a Number variable with the name `count`. To view the value of `count` in a text element, you can add the text  `Count: {{count}}` in the text element. You will then see something similar to what you see in the experience below.&#x20;

To show the value of a variable in a Text element, add the name of the variable you want in **double curly brackets** like `{{variable_name}}`

<figure><img src="https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mgll1jjQMRTVj7p6n7g%2Fuploads%2FjWvWQIyXho9K6bL6aEqb%2Fimage.png?alt=media&#x26;token=5ab58ea3-9574-4fc0-aa53-35f950f3f828" alt=""><figcaption><p>Variable Substitution</p></figcaption></figure>


---

# 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.gmetri.com/metaverse/build/variables/string-substitution.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.
