Examples
The following pages contain specific examples for building custom models to do specific things. They are meant to help you understand how to go about building certain types of custom models and are by no means an exhaustive list of what you can do, and you can mix and match elements to fit your needs.
If you would like to see an example of how this implementation works in practice, check out our example dbt project on Github. It demonstrates how the Unified Digital package can be used as a base for customizations, allowing you modify its behavior without forking the package (e.g. macro overwrite, adding custom data models, overwriting variables etc.).
๐๏ธ Adding Fields to a Derived Table
You may often wish to add fields onto the derived tables within our packages; perhaps there is some additional dimension you need for your analysis, or some extra calculation you wish to perform. In most cases this is relatively straight forward to do, and even in the most complex case you don't need to alter the logic for the derived table itself.
๐๏ธ Daily Aggregate Model
Because of the incremental logic of our packages, all of the this run tables contain events (or a higher level) for only the sessions being processed in that run. For this reason, it is not possible to build daily aggregate tables directly off of any this run tables.
๐๏ธ New Derived Model
We have always seen our packages as a starting point for your analysis and insight generation; there to get you started and give you an idea of what you can do, while providing the framework to build your own models on top to meet your bespoke needs. Assuming that customizing the existing derived tables does not suit your needs the next steps is to create a custom derived model.
๐๏ธ Using multi-valued entities
When building custom derived models you may find yourself needing to use a multi-valued entity, i.e. an entity with multiple entries in the array. These fields should not be extracted as part of the event this run table because it would lead to duplicate rows, and so are only extracted as part of the custom model where you are either keeping the rows at that level or aggregating back up.
๐๏ธ Additional SQL on events this run
Details on how to add sql to the events this run table
๐๏ธ Using Different Sessionisation
Using a different sessionisation is a rare use case for our packages, but can be done in 2 different ways. The use case for each approach is often different so we treat them differently on this page.
๐๏ธ Incorporating non-snowplow data
There may be times when you wish to add some fields to our derived tables that are not coming from the events table itself but from your own external data sources.