Salesforce Marketing Cloud dbt Package (Docs)
This package models Salesforce Marketing Cloud data from Fivetran's connector. It uses data in the format described by this ERD.
The main focus of the package is to transform the core object tables into analytics-ready models:
- Materializes Salesforce Marketing Cloud staging tables which leverage data in the format described by this ERD. The staging tables clean, test, and prepare your Salesforce Marketing Cloud data from Fivetran's connector for analysis by doing the following:
- Primary keys are renamed from
id
to<table name>_id
. - Adds column-level testing where applicable. For example, all primary keys are tested for uniqueness and non-null values.
- Provides insight into your Salesforce Marketing Cloud data across the following grains:
- Email, send, event, link, list, and subscriber
- Primary keys are renamed from
- Generates a comprehensive data dictionary of your Salesforce Marketing Cloud data through the dbt docs site.
The following table provides a detailed list of all models materialized within this package by default.
Tip
See more details about these tables in the package's dbt docs site.
Table | Description |
---|---|
salesforce_marketing_cloud__email_overview | Each record provides the performance of an email via total_* and *_rate metrics. |
salesforce_marketing_cloud__events_enhanced | Each record expands the source events information by pivoting the event_type options into boolean fields. Each record also has related send and email information added. |
salesforce_marketing_cloud__sends_links | Each record provides a link, joined with all corresponding send(s). |
salesforce_marketing_cloud__sends_overview | Each record provides the performance of a send via total_* and *_rate metrics. |
salesforce_marketing_cloud__subscriber_lists | Each record provides a list, joined with all corresponding subscriber(s). |
salesforce_marketing_cloud__subscriber_overview | Each record provides an overview of metrics and activity for a subscriber. |
To use this dbt package, you must have the following:
- At least one Fivetran Salesforce Marketing Cloud connector syncing data into your destination.
- A BigQuery, Snowflake, Redshift, Databricks, or PostgreSQL destination.
If you are using a Databricks destination with this package, you must add the following (or a variation of the following) dispatch configuration within your dbt_project.yml
. This is required in order for the package to accurately search for macros within the dbt-labs/spark_utils
then the dbt-labs/dbt_utils
packages respectively.
dispatch:
- macro_namespace: dbt_utils
search_order: ['spark_utils', 'dbt_utils']
The salesforce_marketing_cloud__events_enhanced
model in this package is materialized incrementally and is configured to work with the different strategies available to each supported warehouse.
For BigQuery and Databricks All-Purpose Cluster runtime destinations, we have chosen insert_overwrite
as the default strategy, which benefits from the partitioning capability.
For all other Databricks runtimes, models are materialized as tables without support for incremental runs.
For Snowflake, Redshift, and Postgres databases, we have chosen delete+insert
as the default strategy.
Regardless of strategy, we recommend that users periodically run a
--full-refresh
to ensure a high level of data quality.
Include the following Salesforce Marketing Cloud package version in your packages.yml
file:
Tip
Check dbt Hub for the latest installation instructions or read the dbt docs for more information on installing packages.
packages:
- package: fivetran/salesforce_marketing_cloud
version: [">=0.2.0", "<0.3.0"] # we recommend using ranges to capture non-breaking changes automatically
By default, this package runs using your destination and the salesforce_marketing_cloud
schema. If this is not where your Salesforce Marketing Cloud data is (for example, if your Salesforce Marketing Cloud schema is named salesforce_marketing_cloud_fivetran
), add the following configuration to your root dbt_project.yml
file:
vars:
salesforce_marketing_cloud_database: your_database_name
salesforce_marketing_cloud_schema: your_schema_name
If you have multiple Salesforce Marketing Cloud connectors in Fivetran and would like to use this package on all of them simultaneously, we have provided functionality to do so. The package will union all of the data together and pass the unioned table into the transformations. You will be able to see which source it came from in the source_relation
column of each model. To use this functionality, you will need to set either the salesforce_marketing_cloud_union_schemas
OR salesforce_marketing_cloud_union_databases
variables (cannot do both) in your root dbt_project.yml
file:
vars:
salesforce_marketing_cloud_union_schemas: ['sfmc_usa','sfmc_canada'] # use this if the data is in different schemas/datasets of the same database/project
salesforce_marketing_cloud_union_databases: ['sfmc_usa','sfmc_canada'] # use this if the data is in different databases/projects but uses the same schema name
NOTE: The native
source.yml
connection set up in the package will not function when the union schema/database feature is utilized. Although the data will be correctly combined, you will not observe the sources linked to the package models in the Directed Acyclic Graph (DAG). This happens because the package includes only one definedsource.yml
.
To connect your multiple schema/database sources to the package models, follow the steps outlined in the Union Data Defined Sources Configuration section of the Fivetran Utils documentation for the union_data macro. This will ensure a proper configuration and correct visualization of connections in the DAG.
By default, this package brings in data from the Salesforce Marketing Cloud link
and list
source tables. However, if you have disabled syncing these sources, you will need to add the following configuration to your dbt_project.yml
:
vars:
salesforce_marketing_cloud__link_enabled: false # default = true
salesforce_marketing_cloud__list_enabled: false # default = true
By default this package will build the Salesforce Marketing Cloud staging models within a schema titled (<target_schema> + _stg_sfmc
) and the Salesforce Marketing Cloud final models within a schema titled (<target_schema> + _sfmc
) in your target database. If this is not where you would like your modeled Salesforce Marketing Cloud data to be written, add the following configuration to your dbt_project.yml
file:
models:
salesforce_marketing_cloud:
+schema: my_new_schema_name # leave blank for just the target_schema
staging:
+schema: my_new_schema_name # leave blank for just the target_schema
If an individual source table has a different name than the package expects, add the table name as it appears in your destination to the respective variable:
Important
See this project's dbt_project.yml
variable declarations to see the expected names.
vars:
salesforce_marketing_cloud_<default_source_table_name>_identifier: your_table_name
Expand for details
Fivetran offers the ability for you to orchestrate your dbt project through Fivetran Transformations for dbt Core™. Learn how to set up your project for orchestration through Fivetran in our Transformations for dbt Core setup guides.
This dbt package is dependent on the following dbt packages. These dependencies are installed by default within this package. For more information on the following packages, refer to the dbt hub site.
Important
If you have any of these dependent packages in your own packages.yml
file, we highly recommend that you remove them from your root packages.yml
to avoid package version conflicts.
packages:
- package: fivetran/fivetran_utils
version: [">=0.4.0", "<0.5.0"]
- package: dbt-labs/dbt_utils
version: [">=1.0.0", "<2.0.0"]
The Fivetran team maintaining this package only maintains the latest version of the package. We highly recommend you stay consistent with the latest version of the package and refer to the CHANGELOG and release notes for more information on changes across versions.
A small team of analytics engineers at Fivetran develops these dbt packages. However, the packages are made better by community contributions.
We highly encourage and welcome contributions to this package. Check out this dbt Discourse article on the best workflow for contributing to a package.
- If you have questions or want to reach out for help, see the GitHub Issue section to find the right avenue of support for you.
- If you would like to provide feedback to the dbt package team at Fivetran or would like to request a new dbt package, fill out our Feedback Form.