--- title: "Store JavaScript Variable and Data for Use in a Transaction Test" slug: "store-javascript-variable-and-data-for-use-in-a-transaction-test" updated: 2023-01-06T15:48:57Z published: 2023-01-06T15:48:57Z canonical: "docs.catchpoint.com/store-javascript-variable-and-data-for-use-in-a-transaction-test" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.catchpoint.com/llms.txt > Use this file to discover all available pages before exploring further. # Store JavaScript Variable and Data for Use in a Transaction Test Catchpoint Transaction tests use [Selenium variables](https://docs.catchpoint.com/docs/Variables-in-Transaction-Tests) to store JavaScript data through the `storeScriptVariable()` command. The `storeScriptVariable()` command saves the value returned from executed JavaScript into a Selenium variable. This can be used to create metrics out of the custom performance mark times for a given page. This is available for Transaction tests using the Chrome monitor. **Syntax:** `storeScriptVariable(name, script)` **Best Practices:** It is recommended that the script called is a single function with a return or a single variable only. If additional JavaScript needs to be injected and executed to initialize the function or variable, it is recommended to use the **[runScript()](https://docs.catchpoint.com/docs/Transaction-Test-Type)** command to perform the injection. The `storeScriptVariable()` should only execute JavaScript functions that have been defined on the page or have been injected with the **[runScript()](https://docs.catchpoint.com/docs/Transaction-Test-Type)** command. **Example:** ``` //Open a page to execute JS on open("http://www.google.com") //Create a JS function that returns 'point' runScript("function bar(){return 'point';}") //Create a variable the concatenates strings and then stores 'catchpoint' runScript("var foo='catch' + bar();") //store JS data into Selenium variable (The second parameter cannot be a JS expression) storeScriptVariable("foobar","foo;") //call the stored Selenium variable to verify its contents open(https://www.google.com/?gws_rd=ssl#q=${var(foobar)}) ``` ***Note that this value can then be made into an insight using either "[setTracepoint](https://docs.catchpoint.com/docs/transaction-commands-and-macros)" or [setIndicator](https://docs.catchpoint.com/docs/transaction-commands-and-macros)".** `setTracepoint(token, ${var(foobar)}) setIndicator(token, ${var(foobar)})`