---
title: "Scripting Recipe Custom Metrics(Kaspersky)"
slug: "scripting-recipe-custom-metricskaspersky"
updated: 2026-05-13T10:25:53Z
published: 2026-05-13T10:25:53Z
canonical: "docs.catchpoint.com/scripting-recipe-custom-metricskaspersky"
---

> ## 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.

# Scripting Recipe Custom Metrics(Kaspersky)

## Objective

This article will give you an example of how to capture custom metrics from the Kaspersky homepage with the help of Catchpoint's[insight](https://docs.catchpoint.com/docs/) feature and store the captured data to analyze it in the portal.

## Prerequisites

- Access to the Catchpoint portal with create/modify test permission.
- Basic understanding of [Navigation Timing API](https://developer.mozilla.org/en-US/docs/Web/API/Navigation_timing_API).
- Working knowledge of   [runScript](https://docs.catchpoint.com/docs/transaction-commands-and-macros#runScript),   [storeScriptVariable](https://docs.catchpoint.com/docs/transaction-commands-and-macros#storeScriptVariable),   and   [setIndicator](https://docs.catchpoint.com/docs/transaction-commands-and-macros#setIndicator)   script commands.

## Process

- Login to the portal
- Set up Insight indicator [(Guide for Insight Settings).](https://docs.catchpoint.com/docs/)
- Create a transaction test or run an instant transaction test using the script given below. ![Pic_9.png](https://cdn.document360.io/cb4af8f9-6751-4fd2-b39c-07aae832badb/Images/Documentation/4402405673997-Pic_9.png)
- Hit Save and your Transaction test to capture custom metrics are ready! ![Pic_11.png](https://cdn.document360.io/cb4af8f9-6751-4fd2-b39c-07aae832badb/Images/Documentation/4402405694605-Pic_11.png)

## Script

```
// Step - 1
open("https://www.kaspersky.co.za/about")
waitForUrl("https://www.kaspersky.co.za/resources/template/html/modules/_shared/components/site-header/templates/search-bar_main-nav.html")
setStepName("1. Africa About Us Page")

// Get the custom metric using JavaScript.
runScript("var timingObj = timing.getTimes(); var firstPaintTimeVal=timingObj.firstPaintTime;")
runScript("var totalLoadTimeVal = performance.timing.loadEventEnd - performance.timing.fetchStart;")
runScript("var totalbackendTimeVal = performance.timing.responseEnd - performance.timing.fetchStart;")
runScript("var totalfrontendTimeVal = (performance.timing.domComplete - performance.timing.domInteractive) + (performance.timing.domInteractive - performance.timing.responseEnd)")
runScript("var backendNetworkTimeVal = performance.timing.connectEnd - performance.timing.connectStart;")

// Store the values in script variable. storeScriptVariable("firstPaintTime", "firstPaintTimeVal;")
storeScriptVariable("totalLoadTime", "totalLoadTimeVal;")
storeScriptVariable("totalbackendTime", "totalbackendTimeVal;")
storeScriptVariable("totalfrontendTime", "totalfrontendTimeVal;")
storeScriptVariable("backendNetworkTime", "backendNetworkTimeVal;")

// store the value in indicator. setIndicator("token_here", "${var(firstPaintTime)}")
setIndicator("token_here", "${var(totalLoadTime)}")
setIndicator("token_here", "${var(totalbackendTime)}")
setIndicator("token_here", "${var(totalfrontendTime)}")
setIndicator("token_here", "${var(backendNetworkTime)}")
```
