By running reflekt dbt, you can create a dbt package the models and documents the events in your tracking plan.

reflekt_dbt.mp4

Naming conventions

When templating a plan (e.g. reflekt dbt --name my-plan --schema my_app_web), Reflekt names folders and files in the default structure shown below:

# In Reflekt project 
dbt-packages
└── reflekt_<project_name>_<cdp>
    ├── analyses
    ├── macros
    ├── models
    │   └── <schema_or_alias>
    │       ├── <docs_prefix>_<schema_or_alias>__<event_name>.yml 
    │       ├── <src_prefix>_reflekt_my_app_web.yml
    │       ├── <model_prefix>_<schema_or_alias>__<event_name>.sql
    │       └── <model_prefix>_<schema_or_alias>__tracks.sql 
    ├── seeds
    ├── snapshots
    ├── tests
    ├── .gitignore
    ├── dbt_project.yml
    └── README.md

Where:

Templating Pages, Screens, Users, and Groups

Unlike events which are custom to your products analytics instrumentation, pages, screens, users, and groups are general concepts in most Customer Data Platforms (e.g. Segment). In order to have Reflekt template dbt sources, models, and docs for these general data sources, you must include the following your analytics governance tool and/or Reflekt tracking plan.

Analytics Governance Tool Reflekt tracking plan Templated files in Reflekt dbt package
Define User traits/properties user-traits.yml <model_prefix>_<schema_or_alias>__users.sql

<docs_prefix><schema_or_alias>__users.yml | | Define Group traits/properties | group-traits.yml | <model_prefix><schema_or_alias>__groups.sql

<docs_prefix><schema_or_alias>__groups.yml | | Define a ‘Page Viewed’ event (in your naming convention) | page-viewed.yml | <model_prefix><schema_or_alias>__pages.sql

<docs_prefix><schema_or_alias>__pages.sql | | Define a ‘Screen Viewed’ event (in your naming convention) | screen-viewed.yml | <model_prefix><schema_or_alias>__screens.sql

<docs_prefix>_<schema_or_alias>__screens.sql |

Additional configurations

Tests

You can configure Reflekt to add a not_null and unique test on the id columns of models it generates. This is configured in the reflekt_project.yml like so: