https://github.com/fivetran/dbt_salesforce_marketing_cloud
Fivetran's Salesforce Marketing Cloud dbt package
https://github.com/fivetran/dbt_salesforce_marketing_cloud
dbt dbt-packages fivetran salesforce-marketing-cloud
Last synced: 6 months ago
JSON representation
Fivetran's Salesforce Marketing Cloud dbt package
- Host: GitHub
- URL: https://github.com/fivetran/dbt_salesforce_marketing_cloud
- Owner: fivetran
- License: apache-2.0
- Created: 2023-12-12T16:42:45.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-28T19:52:41.000Z (about 1 year ago)
- Last Synced: 2024-08-28T21:26:31.314Z (about 1 year ago)
- Topics: dbt, dbt-packages, fivetran, salesforce-marketing-cloud
- Language: Shell
- Homepage: https://fivetran.github.io/dbt_salesforce_marketing_cloud/
- Size: 913 KB
- Stars: 3
- Watchers: 1
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Salesforce Marketing Cloud dbt Package ([Docs](https://fivetran.github.io/dbt_salesforce_marketing_cloud/))
## What does this dbt package do?
This package models Salesforce Marketing Cloud data from [Fivetran's connector](https://fivetran.com/docs/connectors/applications/salesforce-marketing-cloud). It uses data in the format described by [this ERD](https://fivetran.com/docs/connectors/applications/salesforce-marketing-cloud#schemainformation).
The main focus of the package is to transform the core object tables into analytics-ready models:
- Materializes [Salesforce Marketing Cloud staging tables](https://fivetran.github.io/dbt_salesforce_marketing_cloud/#!/overview/salesforce_marketing_cloud/models/?g_v=1) which leverage data in the format described by [this ERD](https://fivetran.com/docs/connectors/applications/salesforce-marketing-cloud/#schemainformation). The staging tables clean, test, and prepare your Salesforce Marketing Cloud data from [Fivetran's connector](https://fivetran.com/docs/connectors/applications/salesforce-marketing-cloud) for analysis by doing the following:
- Primary keys are renamed from `id` to `_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
- Generates a comprehensive data dictionary of your Salesforce Marketing Cloud data through the [dbt docs site](https://fivetran.github.io/dbt_salesforce_marketing_cloud/).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](https://fivetran.github.io/dbt_salesforce_marketing_cloud/#!/overview).| **Table** | **Description**|
| --------- | -------------- |
| [salesforce_marketing_cloud__email_overview](https://fivetran.github.io/dbt_salesforce_marketing_cloud/#!/model/model.salesforce_marketing_cloud.salesforce_marketing_cloud__email_overview) | Each record provides the performance of an email via `total_*` and `*_rate` metrics. |
| [salesforce_marketing_cloud__events_enhanced](https://fivetran.github.io/dbt_salesforce_marketing_cloud/#!/model/model.salesforce_marketing_cloud.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](https://fivetran.github.io/dbt_salesforce_marketing_cloud/#!/model/model.salesforce_marketing_cloud.salesforce_marketing_cloud__sends_links) | Each record provides a link, joined with all corresponding send(s). |
| [salesforce_marketing_cloud__sends_overview](https://fivetran.github.io/dbt_salesforce_marketing_cloud/#!/model/model.salesforce_marketing_cloud.salesforce_marketing_cloud__sends_overview) | Each record provides the performance of a send via `total_*` and `*_rate` metrics. |
| [salesforce_marketing_cloud__subscriber_lists](https://fivetran.github.io/dbt_salesforce_marketing_cloud/#!/model/model.salesforce_marketing_cloud.salesforce_marketing_cloud__subscriber_lists) | Each record provides a list, joined with all corresponding subscriber(s). |
| [salesforce_marketing_cloud__subscriber_overview](https://fivetran.github.io/dbt_salesforce_marketing_cloud/#!/model/model.salesforce_marketing_cloud.salesforce_marketing_cloud__subscriber_overview) | Each record provides an overview of metrics and activity for a subscriber. |
### Materialized Models
Each Quickstart transformation job run materializes 24 models if all components of this data model are enabled. This count includes all staging, intermediate, and final models materialized as `view`, `table`, or `incremental`.## How do I use the dbt package?
### Step 1: Prerequisites
To use this dbt package, you must have the following:- At least one Fivetran Salesforce Marketing Cloud connection syncing data into your destination.
- A **BigQuery**, **Snowflake**, **Redshift**, **Databricks**, or **PostgreSQL** destination.#### Databricks dispatch configuration
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.
```yml
dispatch:
- macro_namespace: dbt_utils
search_order: ['spark_utils', 'dbt_utils']
```#### Database Incremental Strategies
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.
### Step 2: Install the package
Include the following Salesforce Marketing Cloud package version in your `packages.yml` file:
> [!TIP]
> Check [dbt Hub](https://hub.getdbt.com/) for the latest installation instructions or [read the dbt docs](https://docs.getdbt.com/docs/package-management) for more information on installing packages.
```yml
packages:
- package: fivetran/salesforce_marketing_cloud
version: [">=0.2.0", "<0.3.0"] # we recommend using ranges to capture non-breaking changes automatically
```### Step 3: Define database and schema variables
#### Single connection
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:```yml
vars:
salesforce_marketing_cloud_database: your_database_name
salesforce_marketing_cloud_schema: your_schema_name
```
#### Union multiple connections
If you have multiple Salesforce Marketing Cloud connections 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:```yml
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 defined `source.yml`.
To connect your multiple schema/database sources to the package models, follow the steps outlined in the [Union Data Defined Sources Configuration](https://github.com/fivetran/dbt_fivetran_utils/tree/releases/v0.4.latest#union_data-source) 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.
### Step 4: Enable/Disable Variables
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`:```yml
vars:
salesforce_marketing_cloud__link_enabled: false # default = true
salesforce_marketing_cloud__list_enabled: false # default = true
```### (Optional) Step 5: Additional configurations
#### Changing the Build Schema
By default this package will build the Salesforce Marketing Cloud staging models within a schema titled ( + `_stg_sfmc`) and the Salesforce Marketing Cloud final models within a schema titled ( + `_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:```yml
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
```#### Change the source table references
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`](https://github.com/fivetran/dbt_salesforce_marketing_cloud/blob/main/dbt_project.yml) variable declarations to see the expected names.```yml
vars:
salesforce_marketing_cloud__identifier: your_table_name
```### (Optional) Step 6: Orchestrate your models with Fivetran Transformations for dbt Core™
Expand for detailsFivetran offers the ability for you to orchestrate your dbt project through [Fivetran Transformations for dbt Core™](https://fivetran.com/docs/transformations/dbt). Learn how to set up your project for orchestration through Fivetran in our [Transformations for dbt Core setup guides](https://fivetran.com/docs/transformations/dbt#setupguide).
## Does this package have dependencies?
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](https://hub.getdbt.com/) 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.
```yml
packages:
- package: fivetran/fivetran_utils
version: [">=0.4.0", "<0.5.0"]- package: dbt-labs/dbt_utils
version: [">=1.0.0", "<2.0.0"]
```
## How is this package maintained and can I contribute?
### Package Maintenance
The Fivetran team maintaining this package _only_ maintains the latest version of the package. We highly recommend you stay consistent with the [latest version](https://hub.getdbt.com/fivetran/salesforce_marketing_cloud/latest/) of the package and refer to the [CHANGELOG](https://github.com/fivetran/dbt_salesforce_marketing_cloud/blob/main/CHANGELOG.md) and release notes for more information on changes across versions.### Contributions
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](https://discourse.getdbt.com/t/contributing-to-a-dbt-package/657) on the best workflow for contributing to a package.
## Are there any resources available?
- If you have questions or want to reach out for help, see the [GitHub Issue](https://github.com/fivetran/dbt_salesforce_marketing_cloud/issues/new/choose) 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](https://www.surveymonkey.com/r/DQ7K7WW).