Creating Insights

From Gtmhub: Align operations with strategy. Documentation
Jump to: navigation, search

Gtmhub allows you to create custom insights. These insights can be built directly within application. Once you build an insight, you can use it on InsightBoards, as well as in tracking the progress of your goals.

Insights consists of the three components: data, algorithm and user interface. Gtmhub provides numerous features to make the process of creating an insight a simple one. In the this article, we will demonstrate how simple it is to create a Gtmhub insight.

Hello World insight

To begin with, we'll create a simple insight which will only show "hello world" text on InsightBoards. Then, we'll move onto more useful examples.

  • Login to Gtmhub application
  • Click on the Setup tab, the Insights page will open
  • Click on the Build insight button and insight editor will open
  • Set the basic information on insight:
    • Title: Hello World

Title is how we will call your insight in the application

    • Hashtag: hello-world

Hashtag is a unique name of your insight in the application. No two insights can have same hashtag. Hashtag has to start with a letter and contain only letters, numbers and underscores.

    • Description: My very first insight

Description describes the purpose of an insight

  • Click on the Algorithm and Design tab
  • For this simple insight, enter following markup:
<h2>{{ data.message }}</h2>
  • For the algorithm, enter following R code:
out(amount = "Hello World")
  • Click on the Execute button, to execute the algorithm and preview the insight.
  • Click on the Save button. Congratulations, you've just created your very first insight. You can go to InsightBoards and add your new Insight to one of them. Not sure how to do that? Learn how to visualize insights.

This short video demonstrates how to create a Hello World Insight in Gtmhub.

https://www.youtube.com/watch?v=73AYWuDu3yk

Creating an actual insight with metrics

Now that we have seen how easy it is to create a Hello World Insight in Gtmhub, let us create a more useful insight that will use actual data.

For this example, we'll need some data. The simplest way is to install a demo masterplan, which provides data. The demo masterplan creates three entities: Sales Opportunities, Sales Activities and Employees. These entities are populated with real data from a demo instance of MySql.

In this tutorial, we are going to create a simple insight that will show us the distribution of sales opportunities by their value.

  • Login to Gtmhub application
  • Click on the Setup tab, the Insights page will open
  • Before we start, let us examine the available entities. Click on the Entities tab.
  • You can see there are 4 entities present and three of them are connected to data sources (Orders entity is not connected).
  • Click on the Sales Opportunities entity
  • You can see the mappings between the remote data source and your entity, sync status and finally, the entity blueprint. Click on the Entity's blueprint tab
  • Here you can see the name of the entity, which is sales_opp. In addition to this you can see that the entity has four fields named deal_name, sales_rep_email, amount and stage.
  • Now, close the dialog and go back to Insights tab
  • Click on the Build an Insight button
  • Enter the following values for Name and Description:
    • Title: Deal distribution
    • Hash tag: deal-distribution
    • Description: Shows the distribution of deals by the deal size
  • Click on the Algorithm and design tab
    • In the left pane, which defines a view, paste following markup:
<h2>Deals</h2>
<ul>
    <li>Count: {{ data.count | number }}</li>
    <li>
        Large (over $100k): {{ data.large_count }} 
        ({{ data.large_share * 100 | number : 2 }}%)
    </li>
    <li>
        Medium (over $30k): {{ data.medium_count }} 
        ({{ data.medium_share * 100 | number : 2 }}%)
    </li>
    <li>
        Small (below $30k): {{ data.small_count }}
        ({{ data.small_share * 100 | number : 2 }}%)
    </li>
</ul>
  • In the right pane, which defines the algorithm, paste the following code:
deals <- entity("sales_opp")
# Get the number of all deals
summary_all <- summarise(deals,
    count = n()
)
summary_all <- collect(summary_all)
count <- summary_all$count
# Get all deals larger than 100,000
large_deals <- filter(deals, amount > 100000)
# Count the number of large deals
summary_large <- summarise(large_deals,
    count = n()
)
summary_large <- collect(summary_large)
large_count <- summary_large$count
# Get all deals larger or equal to 30,000 and smaller 
# or equal than 100,000
medium_deals <- filter(deals, amount >= 30000 & amount <= 100000)
summary_medium <- summarise(medium_deals,
    count = n()
)
summary_medium <- collect(summary_medium)
medium_count <- summary_medium$count
# Get all deals smaller than 30,000
small_deals <- filter(deals, amount < 30000)
summary_small <- summarise(small_deals,
    count = n()
)
summary_small <- collect(summary_small)
small_count <- summary_small$count
#get all results
large_share <- large_count / count
medium_share <- medium_count / count
small_share <- small_count / count
out(
    count = count,
    large_count = large_count,
    large_share = large_share,
    medium_count = medium_count,
    medium_share = medium_share,
    small_count = small_count,
    small_share = small_share
)
  • Click Execute and you'll see the preview of your deal distribution Insight.

Your screen should look like this:

Deal-distribution-insight.png

  • Click on the Save button

View & Algorithm explanation

We will quickly go through the markup and code we wrote and explain what does it do. You can find more detailed information in regards to this subject in Designing Insights & Insights Algorithms sections.

View

View is designed through standard HTML5. So, you can use all the HTML tags. The values are bound using Angular 1.x syntax.

The important thing to understand here is the relationship between view and algorithm. Algorithm provides the data for the view to display. Any data, that algorithm outputs through the out function, is available to the view through the data object.

The data can be used in the view through following syntax

{{ data.[key] }}

where key is the same key that was used in the out function of the algorithm. In addition to displaying it, data can be manipulated, so we can see how we multiply the share values with 100 to get the percentage. Finally, data can be formatted with pipe symbols. We have formatted percentages as a number with 2 decimal places like this:

{{ data.large_share * 100 | number : 2 }}

Algorithm

Gtmhub uses R language for algorithms. In addition to standard R, Gtmhub preloads some R packages such as dplyr. Finally, Gtmhub provides handful of functions that simplify the work with the platform. The dplyr package is used to retrieve your entities from the Gtmhub data storage engine. dplyr is used to translate the R code into SQL statements that allow us to retrieve the stored data. Since this approach is quite lazy we need to call the collect() function in order to retrieve the calculated results from the data store. More information on how dplyr accesses the databases, refer to this article: dplyr Databases.

First, we have seen the entity function. This function can obtain reference to any of the Gtmhub entities. It takes an entity name as an argument.

Once we have made a reference to the necessary entity we can call the summarise function in order to make the necessary calculations. In order to display the results from those calculations we need to retrieve the results from the data store using collect.

Finally, we have an out function, which provides the way for algorithm to send data to view.

Defining metrics

Gtmhub can take any number as a metric which can be used to track the progress of a goal. So, far our insight had no metrics, so it was not possible for example to track the number of large deals as a metric.

Defining metrics is trivially simple. All we need to do is wrap our data into <metric> tags. Edit the view of our Insight and paste following markup inside:

<h2>Deals</h2>
<ul>
    <li>
        Count: <metric field-name="count">{{ data.count | number }}</metric>
    </li>
    <li>
        Large (over $100k): 
        <metric field-name="large_count">{{ data.large_count }}</metric>
        <metric field-name="large_share">({{ data.large_share * 100 | number : 2 }}%)</metric>
    </li>
    <li>
        Medium (over $30k): 
        <metric field-name="medium_count">{{ data.medium_count }}</metric>
        <metric field-name="medium_share">({{ data.medium_share * 100 | number : 2 }}%)</metric>
    </li>
    <li>
        Small (below $30k): 
        <metric field-name="small_count">{{ data.small_count }}</metric>
        <metric field-name="small_share">({{ data.small_share * 100 | number : 2 }}%)</metric>
    </li>
</ul>

You can see a video demonstrating all the steps above here:

https://www.youtube.com/watch?v=f_IGCbSVoHQ