Working with duration data

This guide explains how to collect and transform duration data, and load it into Adverity Data Storage.

Introduction

The duration data type allows you to collect and display duration data. For more information about data types in Adverity, see Data types used in Adverity.

The procedure described in this guide is represented on data collected from Google Analytics. For other data sources that provide duration data types, follow a similar process to the one outlined below.

Scope

After completing this guide, you will achieve the following:

How to use duration data type in Explore & Present is explained in Creating a Sankey diagram to visualize duration data.

Collecting duration data

To collect fields that include duration data, follow these steps:

  1. Go to the Datastreams page.

  2. In the top right corner, click + Create datastream.

  3. Search for Google Analytics.

  4. Click the Google Analytics button.

  1. Choose one of the following options:

    • If you already have an authorization to Google Analytics, click the existing authorization.

    • To set up the new authorization with your own login credentials, click Setup a new authorization.

    • To ask someone else to set up the new authorization, click Send an access request. In the Email field, write the email address of the person you want to ask to authorize the new authorization. (Optional) Customize the message and set notification preferences. Click Send access request.

  1. Click Custom configuration.

  2. In the Metrics field, write ga:timeOnPage, and select the element from the list.

  1. Click Next.

  1. To assign destinations to your datastream, select their checkboxes. For more information on destinations and their configuration settings, see Loading data into destinations.

  1. Click Next.

  1. Choose the time period for which data is collected.

  1. Click Run fetch.

The fetch collects data from Google Analytics which takes some time. The Overview page of the newly created datastream is now displayed. To preview the collected data, follow these steps:

  1. In the All tasks tab, find the task at the top of the list, and click Show extracts.

  2. Click the top hyperlink.

  3. The data extract is displayed in a table containing the data that you have fetched.

Harmonizing duration data

To harmonize duration data, follow these steps:

  1. Go to the Datastreams page.

  2. Click the Google Analytics datastream that you created in the Collecting duration data section.

  3. In the top navigation panel, click Data Mapping.

  4. In the Name column, find ga:timeOnPage. To the right of this cell, in the corresponding cell of the Target column, write time_on_page and select the element from the list.

    The Data Mapping changes are saved automatically.

Converting duration data to ISO format

The duration data needs to be converted to an ISO format to be loaded into Adverity Data Storage. Use the conversion described in this section if your duration data is not in seconds as integers or duration data in the ISO8601 format.

If your duration data stores seconds as integers or in the ISO8601 format, this conversion does not affect the data.

Creating convertduration script

To create a convertduration script, follow these steps:

  1. Go to the Transformations page.

  2. In the top right corner, click + Create transformation.

  3. Click Custom Script.

  4. In the Assign to section, select Individual Datastreams.

  5. In the drop-down menu, select the Google Analytics datastream that you created in the Collecting duration data section.

  1. Click Next.

  1. In the Select instruction field, write convertduration and select the element from the list.

  2. In Fields, click +, and write ga:timeOnPage.

  3. In the Input duration format field, select Seconds.

  4. Click Next.

  5. (Optional) Rename the transformation.

  6. Click Create +.

Loading duration data into Adverity Data Storage

To load the data from the Google Analytics datastream into Adverity Data Storage, follow the steps set out in Loading data into Adverity Data Storage.

What's next?

To use duration data type in Explore & Present, see Creating a Sankey diagram to visualize duration data.