We welcome Erin Franz, data analyst at Looker, to the Segment blog! Looker is a Segment integration which allows you to explore and visualize the data you collect with Segment, in Looker. Last week, Looker launched Data Actions—yet another way for customers to interact with their Segment data on the Looker platform. Erin will share how you can take advantage of Segment Sources and Looker Data Actions together to operationalize your data.

Leveraging Segment Sources in your centralized data warehouse provides a complete view of each customer. Combining customer event data from mobile and web with data from cloud sources like Salesforce, Zendesk, and Sendgrid gives you actionable insights for sales, customer success, product, and other areas of your business. Using Looker and Looker Blocks on top of the data Segment collects, you can quickly build a centralized data model in Looker with visualization and exploration capabilities, powering everyone’s decision-making with data.

Looker recently launched Data Actions, which is yet another way you can interact with Segment data on the Looker platform. This feature lets you use your external tools to take action without ever leaving Looker. Segment customers can take advantage of Data Actions in the Sources they’re already using today, such as updating a record in Salesforce, triggering an email in SendGrid, or assigning a ticket in Zendesk – all directly from Looker. Let’s walk through a real life example, where we’ll tackle modeling and joining data from Segment’s Salesforce source and Segment customer event data in Looker, and then create a Data Action to trigger an email in SendGrid directly from the Look we’ve created.

Modeling Segment Sources in Looker

Looker’s LookML modeling layer allows you to model data and expose it to your organization without having to move the data from its source. Looker supports all Segment Warehouses endpoints: Postgres, Amazon Redshift, and, most recently, Google BigQuery. Let’s assume we’ve synced Salesforce as a Segment Source in addition to collecting customer event data with Segment’s browser library. We’ll also consider pageviews as an indicator of engagement on our application. We can join our pages table to our Salesforce accounts table by creating the following explore in Looker. We’ll also bring in some contact information to use in the SendGrid Action later.

- explore: pages
  join: groups {
    type: left_outer
    sql_on: ${pages.user_id} = ${groups.user_id}
    relationship: many_to_one
  }
  join: accounts {
    type: left_outer
    sql_on: ${accounts.external_id} = ${groups.group_id}
    relationship: many_to_one
  }
  join: account_contact_role {
    sql_on: ${account.id} = ${account_contact_role.account_id} ;;
    relationship: one_to_many
  }
  join: contact {
    sql_on: ${contact.id} = ${account_contact_role.contact_id} ;;
    relationship: one_to_many
  }

By joining our pageview data to our Salesforce data, we can get engagement insights at the account level that could indicate propensity to churn. For pages, we’ll define measures in our LookML pages view file to help us calculate week over week change in pageview count:

- view: pages {
  sql_table_name: segment.pages
  fields:

  - measure: count_last_week {
      type: count
      filters:  {
        field: received_date
        value: "last week"
      }
    }  

  - measure: count_2_weeks_ago {
      type: count
      filters:  {
        field: received_date
        value: "2 weeks ago for 2 weeks"
      }
    }  

  - measure: week_over_week_change {
      type: number
      sql: (${count_last_week} - ${count_2_weeks_ago})::float/NULLIF(${count_2_weeks_ago},0)
  }
}

Assuming we’ve already defined a dimension for account names in the Account view file, we’ll select Account Name, Pages Count Last Week and Pages Week Over Week change in Looker’s Explore section. (We also added some conditional formatting to Week over Week change to easily identify at risk accounts!)

We now have a list of accounts that have shown a recent decrease in activity. We’d point our account management team to this Look so they can take action on better engaging those accounts.

Closing the Loop: Adding Data Actions

Our account management team could take this list of at-risk customers and take action in external applications like Salesforce or email. But wouldn’t it be easier if they could take action directly from Looker? Let’s add a Data Action to email in the view file for our contacts table. Using the Looker documentation for Data Actions and SendGrid’s Web API docs, we can construct the action in LookML to send an email to the Contact displayed in Looker.

Suppose we want to reach out to Bubble Guru, an account that showed a 74% decrease in usage. We can filter the Account Name on Bubble Guru and add in Contact Email to get a list of emails associated with the account. Now when we click the menu next to each email, we see the option to send Check-in Email.

When we click this option we’ll see a modal window where we can directly compose email from Looker using SendGrid.

Solely using Looker and Segment, we’ve been able to attribute usage data to our accounts, model that data for actionable insights, and take action directly from Looker. We talk to companies all the time about eliminating “data breadlines” — how we can help companies break down data silos and empower business users to get insights from their data. Data Actions is the next step in building a data-driven culture. We can enable teams across an organization to simplify their workflows in Looker with data from Segment, no context switching required.

If you’re not already exploring your data with Looker, we’d love to hear from you!