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. |
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).
- Add the following lines to the bottom of your
dbt_project.yml
file:
repositories:
- https://github.com/jgooly/segment.git
- Run
dbt deps
.
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
These models were written and tested for Redshift only.
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.
- What is dbt?
- Read the dbt viewpoint
- Installation
- Join the chat on Slack for live questions and support.