Segment Metrics dbt Package (Docs)
This package is built on top of dbt-labs-segment package which
- Performs "user stitching" to tie all events associated with a cookie to the same user_id
- Transforms pageviews into sessions ("sessionization")
These packages are under active development and are expected to change with dbt metrics as it evolves over time. As of now, dbt metrics requires users to define models to calculate metrics and these models are persisted on the warehouse. Keeping this in mind, we have currently modelled our packages such that metrics and the models calculating these metrics have a 1:1 mapping, which is why you will see multiple metrics for the same conceptual metric entity accounting for different time grains and dimensions. In future, with the roll out of dbt Server and evolution of dbt metrics, we expect to streamline our packages to remove these redundancies.
The metrics in these packages are transformed on top of source data ETL'd via Fivetran to your warehouse. Make sure you have connected your SaaS source with Fivetran for the packages to work properly.
This package provides pre-built metrics for Segment data from Fivetran's connector. It uses data in the format described by this schema information.
This package enables you to access commonly used metrics on top of Segment Event Data.
This package contains transformed models built on top of dbt-labs Segment. A dependency on the referred package is declared in this package's packages.yml
file, so it will automatically download when you run dbt deps
.
The metrics offered by this package are described below (All metrics are available at daily and monthly granularity)
metric | description |
---|---|
Segment Number of Sessions | Number of app sessions taking place |
Segment Number of Sessions By Device Category | Number of sessions segmented by device category |
Segment Number of Sessions By Referrer Source | Number of sessions segmented by the website that brings the traffic |
Segment Unique Users | Unique users recorded across your website and mobile applications. This is based on the Segment Identify API |
Segment Unique Users Segmented By Country | Unique users recorded across your website and mobile applications segmented by user's country derived from their location. This is based on the Segment Identify API |
Segment Unique Users Segmented By Country and City | unique users recorded across your website and mobile applications segmented by user's country & city derived from their location. This is based on the Segment Identify API |
Segment Page Views | number of page views for your website |
Segment Page Views Segmented By Page Path | number of page views for your website segmented by page path |
Segment Event Count Segmented By Event Type | count of events segmented by event type based on Segment's Track API |
Segment Average Session Duration in Seconds | average session duration in seconds. Sessionization is done on top of data from Segment's Page API |
Segment Average Session Duration in Seconds Segmented By Device Category | average session duration in seconds segmented by device category. Sessionization is done on top of data from Segment's Page API |
Segment Average Session Duration in Seconds Segmented By Referrer Source | average session duration in seconds segmented by source of the traffic. Sessionization is done on top of data from Segment's Page API |
Segment Unique Visitors | number of unique visitors visiting your website. Visitors include anonymous users too |
Segment Unique Visitors Segmented By Country | number of unique visitors visiting your website segmented by user's country derived from their location. Visitors include anonymous users too |
Segment Unique Visitors By Segmented Country and City | number of unique visitors visiting your website segmented by user's country & city derived from their location. Visitors include anonymous users too |
To use this dbt package, you must have the following:
- At least one Fivetran segment connector syncing data into your destination.
- A BigQuery, Snowflake, Redshift, or PostgreSQL destination.
Check dbt Hub for the latest installation instructions, or read the dbt docs for more information on installing packages.
Include in your packages.yml
packages:
- git: "https://github.com/HousewareHQ/dbt_segment_metrics.git"
revision: v1.0.0
By default, this package will look for your Segment data in the fivetran_segment
schema of your target database. If this is not where your Segment data is, please add the following configuration to your dbt_project.yml
file:
# dbt_project.yml
...
config-version: 2
vars:
segment__source: your_database_name
segment_schema: your_schema_name
By default, this package will compute all the metrics in your target
schema inside target
database. It's a good practice to add a suffix to your schema defining what source the metrics are coming from
Go to your dbt_project.yml
file
# dbt_project.yml
...
config-version: 2
models:
segment_metrics:
+schema: segment_metrics
This package has been tested on BigQuery, Snowflake.
Additional contributions to this package are very welcome! Please create issues
or open PRs against main
. Check out
this post
on the best workflow for contributing to a package.
- Provide feedback on what you'd like to see next
- Have questions, feedback, or need help? Email us at nipun@houseware.io
- Check out Houseware's blog
- Learn more about dbt in the dbt docs
- Check out Discourse for commonly asked questions and answers
- Join the chat on Slack for live discussions and support
- Find dbt events near you
- Check out the dbt blog for the latest news on dbt's development and best practices