# Configure the Unified Digital data model
> Configure the Unified Digital dbt package with variables for sessions, users, and views using the interactive config generator.
> Source: https://docs.snowplow.io/docs/modeling-your-data/modeling-your-data-with-dbt/dbt-configuration/unified/
> Documentation index: https://docs.snowplow.io/llms.txt

This page helps you configure the Snowplow Unified Digital dbt package. You can customize variables, generate configuration code, and set output schemas.

## Package configuration variables (v1.0.0)

This package utilizes a set of variables that are configured to recommended values for optimal performance of the models. Depending on your use case, you might want to override these values by adding to your `dbt_project.yml` file.

> **Note: Variable name prefix**
>
> All variables in Snowplow packages start with `snowplow__` but we have removed these in the below tables for brevity.

> **Tip:** When modifying the `session/user_identifiers` or using `session/user_sql` in the unified package these will overwrite the `domain_sessionid` and `domain_userid` fields in tables, rather than being `session/user_identifier` as in the core utils implementation. This is for historic reasons to mitigate breaking changes. Original values for these fields can be found in `original_domain_session/userid` in each table.

### Warehouse and tracker

| Variable | Description | Default |
| --- | --- | --- |
| `database` | The database that contains your atomic events table. | `target.database` |
| `atomic_schema` | The schema (dataset for BigQuery) that contains your atomic events table. | `atomic` |
| `events_table` | The name of the table that contains your atomic events. | `events` |
| `enable_web` | Flag to process web events throughout the package. | `true` |
| `enable_mobile` | Flag to process mobile events throughout the package. | `true` |
| `heartbeat` | Page ping heartbeat time as defined in your [tracker configuration](/docs/sources/web-trackers/tracking-events/activity-page-pings/). | `10` |
| `min_visit_length` | Minimum visit length as defined in your [tracker configuration](/docs/sources/web-trackers/tracking-events/activity-page-pings/). | `5` |
| `rfc_5646_seed` | Name of the model for the RFC 5646 (language) mapping seed table, either a seed or a model (if you want to use a source, create a model to select from it). | `snowplow_unified_dim_rfc_5646_language_mapping` |
| `ga4_categories_seed` | Name of the model for the GA4 category mapping seed table, either a seed or a model (if you want to use a source, create a model to select from it). | `snowplow_unified_dim_ga4_source_categories` |
| `geo_mapping_seed` | Name of the model for the Geo mapping seed table, either a seed or a model (if you want to use a source, create a model to select from it). | `snowplow_unified_dim_geo_country_mapping` |
| `dev_target_name` | The [target name](https://docs.getdbt.com/docs/core/connect-data-platform/profiles.yml) of your development environment as defined in your `profiles.yml` file. See the [Manifest Tables](/docs/modeling-your-data/modeling-your-data-with-dbt/package-mechanics/manifest-tables/) section for more details. | `dev` |
| `grant_schema_usage` | Enables granting usage on schemas interacted with on a dbt run | `true` |
| `grant_select_to` | A list of users to grant select to all tables created by this package to. | `[]` |
| `sessions_table` | The users module requires data from the derived sessions table. If you choose to disable the standard sessions table in favor of your own custom table, set this to reference your new table e.g. `{{ ref(\'snowplow_unified_sessions_custom\') }}`. Please see the [README](https://github.com/snowplow/dbt-snowplow-unified/tree/main/custom_example) in the `custom_example` directory for more information on this sort of implementation. | `"{{ ref( \'snowplow_unified_sessions\' ) }}"` |

### Operation and logic

| Variable | Description | Default |
| --- | --- | --- |
| `start_date` | The date to start processing events from in the package on first run or a full refresh, based on `collector_tstamp` | `2020-01-01` |
| `list_event_counts` | A boolean whether to include a json-type (varies by warehouse) column in the sessions table with a count of events for each `event_type` in that session. | `false` |
| `allow_refresh` | Used as the default value to return from the `allow_refresh()` macro. This macro determines whether the manifest tables can be refreshed or not, depending on your environment. See the [Manifest Tables](/docs/modeling-your-data/modeling-your-data-with-dbt/package-mechanics/manifest-tables/) section for more details. | `false` |
| `backfill_limit_days` | The maximum numbers of days of new data to be processed since the latest event processed. Please refer to the [incremental logic](/docs/modeling-your-data/modeling-your-data-with-dbt/package-mechanics/incremental-processing/#package-state) section for more details. | `30` |
| `days_late_allowed` | The maximum allowed number of days between the event creation and it being sent to the collector. Exists to reduce lengthy table scans that can occur as a result of late arriving data. | `3` |
| `lookback_window_hours` | The number of hours to look before the latest event processed - to account for late arriving data, which comes out of order. | `6` |
| `total_all_conversions` | A boolean flag whether to calculate and add the `cv__all_volume` and `cv__all_total` columns. For more information see the [package documentation](/docs/modeling-your-data/modeling-your-data-with-dbt/dbt-models/dbt-unified-data-model/conversions/). | `false` |
| `conversion_events` | A list of dictionaries that define a conversion event for your modeling, to add the relevant columns to the sessions table. The dictionary keys are `name` (required), `condition` (required), `value`, `default_value`, and `list_events`. For more information see the [package documentation](/docs/modeling-your-data/modeling-your-data-with-dbt/dbt-models/dbt-unified-data-model/conversions/). | `""` |
| `session_identifiers` | A list of key:value dictionaries which contain all of the contexts and fields where your session identifiers are located. For each entry in the list, if your map contains the `schema` value `atomic`, then this refers to a field found directly in the atomic `events` table. If you are trying to introduce a context/entity with an identifier in it, the package will look for the context in your events table with the name specified in the `schema` field. It will use the specified value in the `field` key as the field name to access. For Redshift/Postgres, using the `schema` key the package will try to find a table in your `snowplow__events_schema` schema with the same name as the `schema` value provided, and join that. If multiple fields are specified, the package will try to coalesce all fields in the order specified in the list. For a better understanding of the advanced usage of this variable, please see the [Custom Identifiers](/docs/modeling-your-data/modeling-your-data-with-dbt/package-features/custom-identifiers/) section for more details. | `[{"schema" : "atomic", "field" : "domain_sessionid"}]` |
| `session_sql` | This allows you to override the `session_identifiers` SQL, to define completely custom SQL in order to build out a session identifier for your events. If you are interested in using this instead of providing identifiers through the `session_identifiers` variable, please see the [Custom Identifiers](/docs/modeling-your-data/modeling-your-data-with-dbt/package-features/custom-identifiers/) section for more details on how to do that. | `""` |
| `user_identifiers` | A list of key:value dictionaries which contain all of the contexts and fields where your user identifiers are located. For each entry in the list, if your map contains the `schema` value `atomic`, then this refers to a field found directly in the atomic `events` table. If you are trying to introduce a context/entity with an identifier in it, the package will look for the context in your events table with the name specified in the `schema` field. It will use the specified value in the `field` key as the field name to access. For Redshift/Postgres, using the `schema` key the package will try to find a table in your `snowplow__events_schema` schema with the same name as the `schema` value provided, and join that. If multiple fields are specified, the package will try to coalesce all fields in the order specified in the list. For a better understanding of the advanced usage of this variable, please see the [Custom Identifiers](/docs/modeling-your-data/modeling-your-data-with-dbt/package-features/custom-identifiers/) section for more details. | `[{"schema" : "atomic", "field" : "domain_userid"}]` |
| `user_sql` | This allows you to override the `user_identifiers` SQL, to define completely custom SQL in order to build out a user identifier for your events. If you are interested in using this instead of providing identifiers through the `user_identifiers` variable, please see the [Custom Identifiers](/docs/modeling-your-data/modeling-your-data-with-dbt/package-features/custom-identifiers/) section for more details on how to do that. | `""` |
| `user_stitching_id` | This is the user_id you want to stitch to sessions (and/or page views) with matching domain_userids. It supports raw `sql` expressions. | `user_id` |
| `session_stitching` | Determines whether to apply the user mapping to the sessions table. Please see the [User Mapping](/docs/modeling-your-data/modeling-your-data-with-dbt/package-features/identity-stitching/) section for more details. | `true` |
| `view_stitching` | Determines whether to apply the user mapping to the views table. Note this can be an expensive operation to do every run. One way to mitigate this is by running this update with less frequency than your usual run by enabling this variable only for that specific run. Please see the [User Mapping](/docs/modeling-your-data/modeling-your-data-with-dbt/package-features/identity-stitching/) section for more details. | `false` |
| `session_timestamp` | Determines which timestamp to use for optimizing the queries in our sessionization logic. This should be set to the same timestamp as the field you partition your events table on. This does not affect how sessions are processed and all events will be processed as described in our [sessionization](/docs/modeling-your-data/modeling-your-data-with-dbt/package-mechanics/incremental-processing) logic. | `collector_tstamp` |
| `conversion_stitching` | Determines whether to apply the user mapping to the conversions table. Please see the [User Mapping](/docs/modeling-your-data/modeling-your-data-with-dbt/package-features/identity-stitching/) section for more details. | `true` |
| `custom_sql` | This allows you to introduce custom sql to the `snowplow_unified_events_this_run` table, which you can then leverage in downstream models. For more information on the usage, see the following page on the [advanced usage of the utils package](/docs/modeling-your-data/modeling-your-data-with-dbt/dbt-custom-models/examples/additional-sql-on-events-this-run/). | `""` |
| `cwv_days_to_measure` | The number of days to use for web vital measurements (if enabled). | `28` |
| `cwv_percentile` | The percentile that the web vitals measurements that are produced for all page views (if enabled). | `75` |
| `max_session_days` | The maximum allowed session length in days. For a session exceeding this length, all events after this limit will stop being processed. Exists to reduce lengthy table scans that can occur due to long sessions which are usually a result of bots. | `3` |
| `session_lookback_days` | Number of days to limit scan on `snowplow_unified_base_sessions_lifecycle_manifest` manifest. Exists to improve performance of model when we have a lot of sessions. Should be set to as large a number as practical. | `730` |
| `upsert_lookback_days` | Number of days to look back over the incremental derived tables during the upsert. Where performance is not a concern, should be set to as long a value as possible. Having too short a period can result in duplicates. Please see the [Snowplow Optimized Materialization](/docs/modeling-your-data/modeling-your-data-with-dbt/package-mechanics/optimized-upserts/) section for more details. | `30` |
| `use_refr_if_mkt_null` | Use the refr fields when the mkt fields are null for the definition of default channel group. This is a common case when for example a landing page has a redirect. | `false` |
| `enable_initial_checks` | Use this field to test the existance of all the seed models in the dwh and the existence of contexts that are needed based on your configuration. This is useful when changing the package configuration to ensure quick fails if the configuration is incorrect. | `false` |
| `allow_null_dvce_tstamps` | Use this field to bypass optimization which avoids long scans due to late arriving data. Warning, use this field only when using specific older versions of the AMP tracker or the Pixel tracker. | `false` |
| `license_accepted` | Use this field to accept the Snowplow Personal and Academic License or specify that you have a commercial agreement with Snowplow. | `false` |

### Entities (contexts), filters, and logs

| Variable | Description | Default |
| --- | --- | --- |
| `app_id` | A list of `app_id`s to filter the events table on for processing within the package. | `[ ] (no filter applied)` |
| `ua_bot_filter` | Flag to filter out bots via the `useragent` string pattern match. | `true` |
| `enable_conversions` | Flag to enable the conversions optional module. | `false` |
| `enable_deep_link_context` | Flag to include the deep link context data in the models. | `false` |
| `enable_geolocation_context` | Flag to include the geolocation data in the models. | `false` |
| `enable_iab` | Flag to include the [IAB enrichment](/docs/enriching-your-data/available-enrichments/iab-enrichment/) data in the models. | `false` |
| `enable_yauaa` | Flag to include the [YAUAA enrichment](/docs/enriching-your-data/available-enrichments/yauaa-enrichment/) data in the models. | `false` |
| `enable_ua` | Flag to include the [UA Parser enrichment](/docs/enriching-your-data/available-enrichments/ua-parser-enrichment/) data in the models. | `false` |
| `enable_browser_context` | Flag to include fields extracted from the [Browser context](/docs/collecting-data/collecting-from-own-applications/snowplow-tracker-protocol/ootb-data/device-and-browser/index.md#browser-context) data in the models (JS tracker <3.17), can be used together with `snowplow__enable_browser_context_2` (supports 2nd major schema version) to coalesce the two. | `false` |
| `enable_browser_context_2` | Flag to include fields extracted from the 2nd major version of schemas related to the [Browser context](/docs/collecting-data/collecting-from-own-applications/snowplow-tracker-protocol/ootb-data/device-and-browser/index.md#browser-context) data in the models (JS tracker (>=3.17), can be used together with `snowplow__enable_browser_context` for previous versions to coalesce the two. | `false` |
| `conversion_passthroughs` | Field(s) to carry through from the events table to the derived table. The field is based on the events_this_run table therefore taking all events. Aggregation is not supported. A list of either flat column names from the events table or a dictionary with the keys `sql` for the SQL code to select the column and `alias` for the alias of the column in the output.  See the [Passthrough field](/docs/modeling-your-data/modeling-your-data-with-dbt/package-features/passthrough-fields/) docs for more information.Note flat fields will be aliased with a `last_` prefix, dictionary provided aliases will not by default. | `[ ] (no passthroughs)` |
| `enable_app_errors` | Flag to include the mobile app error data in the models. | `false` |
| `enable_application_context` | Flag to include the app context data in the models. | `false` |
| `enable_consent` | Flag to enable the [consent](/docs/modeling-your-data/modeling-your-data-with-dbt/dbt-models/dbt-unified-data-model/consent-module/) module. | `false` |
| `enable_cwv` | Flag to enable the [Core Web Vitals](/docs/modeling-your-data/modeling-your-data-with-dbt/dbt-models/dbt-unified-data-model/core-web-vitals-module/) module. | `false` |
| `enable_mobile_context` | Flag to include mobile context data in the models | `false` |
| `enable_screen_context` | Flag to include the mobile screen data in the models. | `false` |
| `enable_screen_summary_context` | Flag to process the screen engagement information in the screen summary context on mobile events. | `false` |
| `has_log_enabled` | When executed, the package logs information about the current run to the CLI. This can be disabled by setting to `false`. | `true` |
| `session_aggregations` | Aggregations to calculate as part of the the derived table. A list of dictionaries defining the type (sum, avg, min, max, count, countd), field to aggregate, and what to alias the column. | `[ ] (no aggregations)` |
| `session_passthroughs` | Field(s) to carry through from the events table to the derived table. The field is based on the first `page/screen_view` or `page_ping` event for that session. Aggregation is not supported. A list of either flat column names from the events table or a dictionary with the keys `sql` for the SQL code to select the column and `alias` for the alias of the column in the output. | `[ ] (no passthroughs)` |
| `user_aggregations` | Aggregations to calculate as part of the the derived table. A list of dictionaries defining the type (sum, avg, min, max, count, countd), field to aggregate, and what to alias the column. | `[ ] (no aggregations)` |
| `user_first_passthroughs` | Field(s) to carry through from the events table to the derived table. The field is based on the first session record for that user. Aggregation is not supported. A list of either flat column names from the sessions table or a dictionary with the keys `sql` for the SQL code to select the column and `alias` for the alias of the column in the output. | `[ ] (no passthroughs)` |
| `user_last_passthroughs` | Field(s) to carry through from the events table to the derived table. The field is based on the last session record for that user. Aggregation is not supported. A list of either flat column names from the sessions table or a dictionary with the keys `sql` for the SQL code to select the column and `alias` for the alias of the column in the output. See the [Passthrough field](/docs/modeling-your-data/modeling-your-data-with-dbt/package-features/passthrough-fields/) docs for more information. Note flat fields will be aliased with a `last_` prefix, dictionary provided aliases will not by default. | `[ ] (no passthroughs)` |
| `view_aggregations` | Aggregations to calculate as part of the the derived table. A list of dictionaries defining the type (sum, avg, min, max, count, countd), field to aggregate, and what to alias the column. | `[ ] (no aggregations)` |
| `view_passthroughs` | Field(s) to carry through from the events table to the derived table. The field is from the `page/screen_view` event record. Aggregation is not supported. A list of either flat column names from the events table or a dictionary with the keys `sql` for the SQL code to select the column and `alias` for the alias of the column in the output. See the [Passthrough field](/docs/modeling-your-data/modeling-your-data-with-dbt/package-features/passthrough-fields/) docs for more information. | `[ ] (no passthroughs)` |

### Warehouse-specific

| Variable | Description | Default | Warehouse |
| --- | --- | --- | --- |
| `databricks_catalog` | The catalogue your atomic events table is in. Depending on the use case it should either be the catalog (for Unity Catalog users from databricks connector 1.1.1 onwards, defaulted to `hive_metastore`) or the same value as your `snowplow__atomic_schema` (unless changed it should be 'atomic'). | `hive_metastore` | Databricks |
| `derived_tstamp_partitioned` | Boolean to enable filtering the events table on `derived_tstamp` in addition to `collector_tstamp`. | `true` | Bigquery |
| `enable_load_tstamp` | Flag to include the `load_tstamp` column in the base events this run model. This should be set to true (the default) unless you are using the Postgres loader or an RDB loader version less than 4.0.0. It must be true to use consent models on Postgres and Redshift. | `true` | Redshift |
| `entities_or_sdes` | A list of dictionaries defining the `entity` or `self-describing` event tables to join onto your base events table. Please use the tool below or see the section on [Utilizing custom contexts or SDEs](/docs/modeling-your-data/modeling-your-data-with-dbt/package-features/modeling-entities/) for details of the structure. | `[]` | Redshift |
| `snowflake_lakeloader` | To use the models on an iceberg events table created via the lakeloader on Snowflake, this will need to be enabled due to different table structures. | `false` | Snowflake |

