Skip to content

jgooly/segment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Segment DBT Data Models


Models

The primary data models contained in this package are described below. While other models exist, thse are the models primarily used to build the three primary models listed here.

These models can be used to build other custom models to fit your use case.

model description
segment_universal_user_id Contains the cononical mapping of many anonymous ids to a single universal id per user.
segment_mapped_pages Contains the Segment 'pages' table with the universal id mapped to each record.
segment_mapped_events Contains the Segment 'tracks' table with the universal id mapped to each record.
segment_mapped_actions Contains the union of the 'segment_mapped_pages' model and 'segment_mapped_events' model.
segment_sessions Contains the start and end of each user session and session id.
segment_sessions_map Contains the 'segment_mapped_actions' model with session ids mapped to each track or page call.

Model Graph

segment graph

How You Might Use These Models

These "foundational" models can be used to calculate aggregrated statistics or branched out to create new complex models.

For example, the segment_sessions model can be used to calculated statistics like monthly active users (MAUs), daily active users (DAUs), weekly active users (WAUs), and more.

An example of branching out these models for more complex or specific analysis might include using the segment_mapped_actions model to better understand key events that lead to purchases (inversely, funnel dropout).

Installation

  1. Add the following lines to the bottom of your dbt_project.yml file:
repositories:
  - https://github.com/jgooly/segment.git
  1. Run dbt deps.

Configuration

The base variables needed to configure this package are as follows:

variable information required
segment.pages The Segment pages table in warehouse (usually something like segment.pages). Yes
segment.tracks The Segment tracks table in warehouse (usually something like segment.tracks). Yes
segment.users The Segment users table in warehouse (usually something like segment.users). No
segment.identifies The Segment identifies table in warehouse (usually something like segment.identifies). No

An example of the dbt_project.yml file:

# dbt_project.yml

...

models:  
  segment:
    enable: true
    materialized: view
    utility_models:
      materialized: view
    base:
      materialized: view
      vars:
        "base.pages" : "segment.pages"
        "base.tracks" : "segment.tracks"
        "base.users" : "segment.users"
        "base.identifies" : "segment.identifies"

...

repositories:
 - https://github.com/jgooly/segment

Database Support

These models were written and tested for Redshift only.

Contributions

Additional contributions to this repo are very welcome! Please submit PRs to master. All PRs should only include functionality that is contained within all Segment deployments; no implementation-specific details should be included.


Want to Know More About DBT?