Skip to main content
Gainsight Inc.

Aggregate Usage Data with Rules Engine

Gainsight NXT

 

Introduction

In this tutorial, we will use Rules in order to query for usage data related to page views and then pivot the data to aggregate it either by week or by month. This will be accomplished by creating a Dataset Task that queries the usage data within the MDA, and then creating a separate Dataset Task that pivots the data and completes the aggregation.

Following are the goals we intend to achieve using a single rule:

  1. Create Dataset to Fetch Data from MDA.
  2. Create Dataset to Pivot on Pages data.

Fetch Data from MDA

  1. In this step, Navigate to Administration > Rules Engine and create a Rule that enables you to fetch data from MDA.

Create Rule

  1. Enter following details in the Create Rule page:
  • Rule For: Select Company.
  • Rule Name: Enter an appropriate name.
  • Folder: Select a folder for the rule.
  • Description: Enter description (optional).
  • Click NEXT. Setup Rule page appears.

clipboard_e967a76f48b7b6541c91afef51d032b40.png

Setup Rule

  1. In the Setup Rule, click DATASET in order to begin creating the tasks the rules will need to complete.

clipboard_e47f249860d2f2110a0f7969fcd63e5c9.png

  1. Set a Task Name and an Output Dataset Name for your Dataset Task. The Task Name will be used to identify the task within the rule, while the Output. 

    Dataset Name will be used to identify the resulting dataset after the task is completed. Gainsight recommends adding a Task Description with more details about the dataset.

    In our example, this task will fetch data from the MDA and then pivot on the Page Name; so we have named the task, its description, and its output dataset name, accordingly.
  2. Click SAVE.

Name the Dataset.png

 

  1. Since the goal of this rule is to fetch data from the MDA, select the object that you previously uploaded your Usage Data into.

  2. Add the fields that you would like to reference as part of the pivot and the aggregation and add them to the Show section. In our example, we’ve selected the example object Usage Data. In the Show section, we’ve added the fields Company and Company Name (in order to tie this data back to those records). We’ve also added Date Field, Page Name, and Views as those will be necessary fields for the Pivot and Aggregation.

Configuring Dataset for Pivot task.png 

Note: While not necessary to complete this tutorial, each Dataset Task also has a section for exporting the resulting data to the S3. For more information on the options presented, click here. Select the exporting option that works best for your team.

  1. Click SAVE in the top-right to save the task.

Pivot on Pages Data

  1. Go back to the Setup Rule and click +TASK in order to add a new Dataset Task and Select Pivot to complete pivot and aggregate the usage data.

Select Pivot task.png 

  1. Enter the Task Name, Task Description, and Output Dataset Name for this task. Following example shows the Task Name and Output Dataset Name as this task is to pivot on page data and aggregate by date.

Configure pivot task.png

  1. Under Dataset, select Fetch from MDA in order to pull in the data fetched by the previous task. Also add the fields Date Field and Company into the Show section, to give reference that data within the task.

Configure pivot show section_1.png

  1. Drag the Page Name field and drop it under the Pivot On section. The Pivot conditions to evaluate window is displayed.

Pivoting on Page Name field.gif

  1. Configure the conditions as shown below:
    1. Values of the Page Name
    2. Use the Output Field Label column to determine how the pivoted data will be identified,
    3. Aggregation column to determine how the data will be aggregated.
    4. Field column to determine what data will be selected as part of the pivot.
    5. Default Value column to determine value of data that is fetched, but does not meet the pivot condition. Set this to 0, to avoid views from other pages to throw off our aggregations.
  2. In the following example, various aggregation methods are used on three pages: 
    Click +ADD to add additional rows.

Configure Pivot table_1.png

  1. Click OK to set the conditions.

In the GroupBy section, add Date Field and Company Name to ensure the aggregation successfully groups the data by time for each company. When you drag the Date field to Group By section, Company Name field automatically changes to Count of Company , in the Show section. You must change this aggregation and then drag and drop the Company Name field to GroupBy section.

Group by Date field and Company Name.gif

  1. Click the gear icon on the Date Field in order to select how frequently you would like the aggregation to be grouped by. For weekly aggregation, select First Day of Current Week or Last Day of Current Week. For monthly aggregation, select First Day of Current Month or Last Day of Current Month.

Summarizing Date field.png

  1. Click SAVE.

These actions aggregate page views successfully for each company either weekly or monthly. You can then setup any action on this data in the Setup Action page. For more information on how to set rule actions, check the article Setup Rule Action Types. 

  • Was this article helpful?