In this article, you will learn how to calculate the time spent in a node.

Step 1: Create custom fields

Create a custom field for the timestamp on node enter.

Create a custom field for the timestamp on node exit.

Create a calculated custom field for the time spent. Please do not forget to include the formula as shown in the image below.

Step 2: Add node level scripts

In a node, click the “Add Scripts” button as shown below.

Add the script below in “Enter”.

<script>
 let time = {_c_eventtime}
 DT.setField('time_enter', time);
</script>

Add the script below in “Exit”.

<script>
  let time = {_c_eventtime};
  DT.setField('time_exit', time);
</script>

The Custom Field time_spent will automatically calculate the time difference between the time you entered the node to the time you exit the node. The result will be in seconds.

Leave a Reply

Your email address will not be published.