# Transactions

Any sequence of interactions or page clicks can be grouped as a transaction. Transactions are mechanisms to measure server response time for any operation. In simple words, the use of the word “Transaction” helps to measure the time taken by the system for a particular request.

## Need of Transaction

Transactions in Script are needed due to the following reasons:

- To measure server response time for a particular user request/action.
- To measure server response time for a logical group of actions. For Example, to measure the response time of a checkout having 3 pages, users can group them into a transaction of the group.

## Start Transaction

In script, Transactions API(ns_start_transaction) can be used anywhere in the flow files. Start transaction is normally added before ns_web_url API.

Alternatively, start a transaction before the main URL.

Example:

voidflow()
{
// Using transaction for home page
ns_start_transaction("HomePage");
ns_web_url ("Homepage", "URL=http://127.0.0.1/tours/index.html");
ns_end_transaction ("HomePage", NS_AUTO_STATUS);
}

1. Enter the transaction name and click Advanced
2. In Advanced, you have the following options of whether you want:

- Transaction Name as a text: In this, The transaction name is taken as plain text.
- Transaction Name as a Variable: In this, The transaction name is taken as a programming variable and the value of that parameter is used as the transaction name.
- Transaction name as a Script parameter: In this, The transaction name is taken as a script parameter and the value of that parameter is used as a transaction name.