---
title: "Setting site variables on websites"
date: "2024-02-14T06:18:38+00:00"
summary: "Learn how to set, manage, and use site variables in Site Factory for enhanced website customization and security."
image:
type: "page"
url: "/site-factory/setting-site-variables-websites"
id: "3951cc87-7945-4e4a-8755-35eca45ae491"
---

You can set site variables for each site managed by Site Factory. Site variables can be removed as part of the staging process if they contain sensitive data, such as API keys.

Site variables are available for Site Factory sites according to the following requirements:

*   Each site can have a maximum of 10 site variables defined.
*   Any of the site variable keys must not contain any spaces.
    
*   Each site variable key can have a maximum length of 25 characters.
*   Each site variable value can have a maximum length of 50 characters.

When managing site variables, review the following expected functionality:

*   Site variables are not copied between sites when a site is duplicated.
*   Selecting the **Remove during staging** checkbox when defining a site variable removes the site variable from the site when staging it to a lower environment. The production environment is unaffected.
*   After you add a new site variable, the system might take a few minutes to make the site variable available on the site.
*   If you do not select the **Wipe target environment** option, Site Factory does not copy site variables during the stage down process as they are part of Factory database and not the site database.

Creating site variables
-----------------------

### Using the Site Factory user interface

To create site variables using the Site factory user interface:

1.  [Sign in](/site-factory/login) to the Site Factory Management Console.
2.  Find the site for which you want to manage site variables.
3.  Click the dropdown arrow next to **Login** to open the **Actions** menu for the site.
    
    ![site-factory_site-variables.png](https://acquia.widen.net/content/991c03af-1231-4794-bc9b-f36f5da260dc/web/site-factory_site-variables.png)
    
4.  Click **Configure Site Variables**.
5.  Use the page controls to add, edit, or remove the site variables for the site.
    
    After you add a new site variable, the system might take a few minutes to make the site variable available on the site.
    

### Using Acquia CLI

To create site variables using Acquia CLI, run the following command:

    acli acsf:sites:set-site-variable 

To remove site variables using Acquia CLI, run the following command:

    acli acsf:sites:remove-site-variable

Note

When you create or remove site variables using Acquia CLI, you must run the following command to verify that the changes are propagated to the Drupal site:

    acli acsf:sites:distribute-site-variables

Using the site variable in the site code
----------------------------------------

You can access defined variables within the site code using the following variable:

    $GLOBALS['gardens_site_settings']['flags']
    ```
    Example array:
    ```
    array(3) {
       ["external_service_api_key"]=>
       string(13) "apikey-value2"
       ["non-secret-key"]=>
       string(7) "value-2"
       ["external_service_api_key_non-secret"]=>
       string(19) "apikey-value xx1234"
    }
    ```