# Transactions

Any sequence of interactions or page clicks can be grouped as a transaction. Transactions are mechanism 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.

## End transaction

In script, Transactions API can be used anywhere in the flow files. End Transaction is normally before ns_page_think_time API.

Alternatively, end the transaction after the URL.

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 End Transaction Name or select from the available list of started transactions.
2. In Advanced, you have the following options:

- Status: It shows the status of the transaction, which can be passed, failed or auto status.
- 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 value of that parameter is used as transaction name.
- Transaction name as a Script parameter: In this, The transaction name is taken as a script parameter and value of that parameter is used as a transaction name.End transaction as different name: If you want to end the transaction as a different name, you have to select this checkbox. You will get the option to fill the new name and also to select whether you want the end transaction as text, variable, or Script manager.