Code Monkey home page Code Monkey logo

dbt_marketo_source's Introduction

Marketo Source dbt Package (docs)

πŸ“£ What does this dbt package do?

  • Produces staging tables that leverage Marketo data from Fivetran's connector in the format described by this ERD.
    • Adds descriptions to tables and columns that are synced using Fivetran
    • Models staging tables, which will be used in our transform package
    • Adds column-level testing where applicable. For example, all primary keys are tested for uniqueness and non-null values.
  • Generates a comprehensive data dictionary of your source and modeled Marketo data through the dbt docs site.
  • These tables are designed to work simultaneously with our Marketo transformation package.

🎯 How do I use the dbt package?

Step 1: Prerequisites

To use this dbt package, you must have the following:

  • At least one Fivetran Marketo connector syncing data into your destination.
  • A BigQuery, Snowflake, Redshift, PostgreSQL, or Databricks destination.

Databricks Dispatch Configuration

If you are using a Databricks destination with this package you will need to add the below (or a variation of the below) 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']

Step 2: Install the package (skip if also using the Marketo transformation package)

If you are not using the Marketo transformation package, include the following package version in your packages.yml file. If you are installing the transform package, the source package is automatically installed as a dependency.

TIP: Check dbt Hub for the latest installation instructions or read the dbt docs for more information on installing packages.

packages:
  - package: fivetran/marketo_source
    version: [">=0.11.0", "<0.12.0"]

Step 3: Define database and schema variables

By default, this package runs using your destination and the marketo schema of your target database. If this is not where your Marketo data is (for example, if your Marketo schema is named marketo_fivetran), add the following configuration to your root dbt_project.yml file:

vars:
  marketo_database: your_database_name
  marketo_schema: your_schema_name 

Step 4: Enabling/Disabling Models

This package takes into consideration tables that may not be synced due to slowness caused by the Marketo API. By default the campaign and program models are disabled. If you sync these tables, enable the modeling done by adding the following to your dbt_project.yml file:

vars:
    marketo__enable_campaigns:   true      # Enable if Fivetran is syncing the campaign table
    marketo__enable_programs:    true      # Enable if Fivetran is syncing the program table

Alternatively, you may need to disable certain models. The below models can be disabled by adding them to your dbt_project.yml file:

vars:
    marketo__activity_delete_lead_enabled:  false     # Disable if you do not have the activity_delete_lead table 

(Optional) Step 5: Additional configurations

Expand for details

Passing Through Additional Columns

This package includes all source columns defined in the macros folder. If you would like to pass through additional columns to the staging models, add the following configurations to your dbt_project.yml file. These variables allow for the pass-through fields to be aliased (alias) and casted (transform_sql) if desired, but not required. Datatype casting is configured via a sql snippet within the transform_sql key. You may add the desired sql while omitting the as field_name at the end and your custom pass-though fields will be casted accordingly. Use the below format for declaring the respective pass-through variables in your root dbt_project.yml.

vars:
    marketo__activity_send_email_passthrough_columns: 
      - name: "new_custom_field"
        alias: "custom_field_name"
        transform_sql:  "cast(custom_field_name as int64)"
      - name: "a_second_field"
        transform_sql:  "cast(a_second_field as string)"
    # a similar pattern can be applied to the rest of the following variables.
    marketo__program_passthrough_columns:

Changing the Build Schema

By default this package will build the Marketo staging models within a schema titled (<target_schema> + _marketo_source) in your target database. If this is not where you would like your Marketo data to be written to, add the following configuration to your dbt_project.yml file:

models:
  marketo_source:
    +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 what 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:
    marketo_<default_source_table_name>_identifier: "your_table_name"

(Optional) Step 6: Orchestrate your models with Fivetran Transformations for dbt Coreβ„’

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.

πŸ” Does this package have dependencies?

This dbt package is dependent on the following dbt packages. Please be aware that 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"]

    - package: dbt-labs/spark_utils
      version: [">=0.3.0", "<0.4.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 of the package and refer to the CHANGELOG 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 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, please refer to 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.
  • Have questions or want to just say hi? Book a time during our office hours on Calendly or email us at [email protected].

dbt_marketo_source's People

Contributors

dylanbaker avatar fivetran-catfritz avatar fivetran-chloe avatar fivetran-jamie avatar fivetran-joemarkiewicz avatar fivetran-reneeli avatar fivetran-sheringuyen avatar jlmendgom5tran avatar kristin-bagnall avatar sisu-callum avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dbt_marketo_source's Issues

[Bug] make sure timestamps do not have time zones

Is there an existing issue for this?

  • I have searched the existing issues

Describe the issue

reported by @calder-holt

in the transform package we're seeing dateadd-related issues because activity_timestamp is getting piped in as a timestamp with time zone (on redshift). similar to our other packages, we'll need to cast this field as {{ dbt_utils.type_timestamp() }} (aka timestamp without time zone) preemptively

Relevant error log or model output

No response

Expected behavior

date functions shouldn't fail and the timestamps shouldn't have time zones

dbt Project configurations

na

Package versions

na

What database are you using dbt with?

redshift

dbt Version

na

Additional Context

No response

Are you willing to open a PR to help address this issue?

  • Yes.
  • Yes, but I will need assistance and will schedule time during our office hours for guidance
  • No.

[Bug] Under-reporting of metrics for Nurture Campaigns (Or campaigns with multiple emails)

Is there an existing issue for this?

  • I have searched the existing issues

Describe the issue

Our Market Intelligence team was recently working on revamping our email analytics dashboard. While working through the stakeholder requirements and QC'ing the data with Marketo numbers on front end, we noticed that our nurture campaign numbers were under-reported, drastically!
While digging deeper into this, we identified that the [rank partition] we create using the "concatenated" email_send_id in the Fivetran Marketo DBT package on github, that is resulting in incorrectly filtering the data out which we want to report on.
The issue is with the concatenated "email send id" which is combination of "campaign_id || ',' || campaign_run_id || ',' || lead_id as email_send_id. It seems the concatenation assumes that a program can have one or more campaigns with multiple runs but only one email since primary_attribute_value_id is not concatenated in the email_send_id. The current setup works when the emails are one-off emails but when they are nurture emails where we have multiple emails under one nurture campaign.
We think the fix to this is to also concatenate primary_attribute_value_id as part of the email_send_id, but happy to be work through the team to discuss the issue as well as the solution.

I have created the issue in this repo because once we fix the concatenated string, the rank partition should be able to report appropriately.

Let me know if you have any questions.

Relevant error log or model output

No response

Expected behavior

When we filter the data based on rank=1 partition, our expectations are that all activities after the first interaction is filtered out at the email level, while the current code filters all the activities at a campaign level. So if a campaign had multiple emails, say E1,E2,E3 with EMAIL_OPEN activity for each of the emails. With current set up, I only see E1 EMAIL_OPEN activity in the data and all other subsequent EMAIL_OPEN activity are filtered out because the ranking of activity happens are campaign level(with lead_id) and not on email level.

The straight-forward fix to this I believe is to include primary_attribute_value as part of the surrogate/concatenated key. I have tested the new code and it works as expected and QC'd the numbers with Marketo numbers too!

Open to suggestions and quick fix to this will be appreciated.

Thanks

dbt Project configurations

project name

name: 'marketing'
version: '0.0.1'

config-version: 2

default profile for project (profiles are configured in the ~/.dbt/profiles.yml file)

profile: 'default'

how to handle quoting

quoting:
identifier: false
schema: false

location of assets in project

model-paths: ["models"]
analysis-paths: ["analysis"]
test-paths: ["tests"]
seed-paths: ["data"]
macro-paths: ["macros"]
target-path: "target" # directory which will store compiled SQL files
clean-targets: # directories to be removed by dbt clean
- "target"
- "dbt_modules"

post-run commands to execute

models:
marketing:
post-hook:

tests:
+store_failures: true
+schema: dbt_tests
+severity: warn

Package versions

packages:

  • package: fivetran/ad_reporting
    version: [">=0.7.0", "<0.8.0"]

What database are you using dbt with?

snowflake

dbt Version

1.1.0

Additional Context

No response

Are you willing to open a PR to help address this issue?

  • Yes.
  • Yes, but I will need assistance and will schedule time during our office hours for guidance
  • No.

[Feature] align `campaign` and `program` with connector updates

Is there an existing feature request for this?

  • I have searched the existing issues

Describe the Feature

There have been updates to the connector that the package should probably fold in:

  • New fields (including = _fivetran_deleted flags) added to the program and campaign tables
  • Custom columns now added to program -> let's add passthrough columns and check if we need to add them to any other models (i would guess campaign too)
  • deprecated program_name field from the campaign table

Describe alternatives you've considered

don't update

Are you interested in contributing this feature?

  • Yes.
  • Yes, but I will need assistance and will schedule time during your office hours for guidance.
  • No.

Anything else?

No response

[Feature] Update staging models to follow best practices

Is there an existing feature request for this?

  • I have searched the existing issues

Describe the Feature

The stg_marketo__lead model has a lot of transformation logic included within it. This does not align with our best practices where we intend to keep the staging models as simply cleaning and prepping of the data. Instead we are perform pretty heavy intermediate logic within this staging model.

We will want to move this logic into the dbt_marketo package at the next breaking change.

Describe alternatives you've considered

Keeping the logic where it is. However, this does not align with our package modeling principles and should be transitioned into the transformation package.

Are you interested in contributing this feature?

  • Yes.
  • Yes, but I will need assistance and will schedule time during your office hours for guidance.
  • No.

Anything else?

I only dug into the stg_marketo__lead. However, it would be beneficial to look into a few of the other staging models to ensure the modeling practices are in alignment with our best practices.

FEATURE - Ability to remove tables from model if required

Are you a Fivetran customer?
Nicolas Soria, Data Engineer from Hopin

Is your feature request related to a problem? Please describe.

While trying to use the Marketo dbt package, a table which is required by the models is coming empty from the Fivetran connector.
The table is activity_delete_lead .

Describe the solution you'd like
A potential solution could be a flag in the dbt_profile.yml file that allows us to disable the use of mentioned table in case it comes empty from the integrations.

Describe alternatives you've considered
N/A

Additional context
N/A

Please indicate the level of urgency and business impact of this request
This will help us to replicate reports from Marketo.

Are you interested in contributing to this package?

  • Yes, I can do this and open a PR for your review.
  • Possibly, but I'm not quite sure how to do this. I'd be happy to do a live coding session with someone to get this work implemented.
  • No, I'd prefer if someone else did this. I don't have the time and/or don't know how to incorporate the changes necessary.

[Feature] expand default `LEAD` columns

Is there an existing feature request for this?

  • I have searched the existing issues

Describe the Feature

currently, we include all columns we find in stg_marketo__lead, but we only ensure that the following fields are included in the table: ['id', 'created_at', 'updated_at', 'email', 'first_name', 'last_name', '_fivetran_synced']. These are the only fields we include in the get_lead_columns() macro.

However, there are quite a few more default fields for the LEAD table, which are outlined here.

Some of these fields will be necessary for our upcoming Customer360 work, namely:

  • phone
  • main_phone
  • mobile_phone
  • company
  • inferred_company
  • address_lead
  • address
  • city
  • state
  • state_code (not in this doc but we have it internally?)
  • country
  • country_code (not in this doc but we have it internally?)
  • postal_code
  • billing_street
  • billing_city
  • billing_state
  • billing_state_code (not in this doc but we have it internally?)
  • billing_country
  • billing_country_code (not in this doc but we have it internally?)
  • billing_postal_code
  • inferred_city
  • inferred_state_region
  • inferred_country
  • inferred_postal_code
  • inferred_phone_area_code
  • anonymous_ip
  • unsubscribed
  • email_invalid
  • do_not_call

In the off chance that a user does not have the above, I'd like to ensure that the customer360 package runs successfully. Thus, let's add these columns to the get_lead_columns macro and to this line and document them in yml.

Describe alternatives you've considered

No response

Are you interested in contributing this feature?

  • Yes.
  • Yes, but I will need assistance and will schedule time during your office hours for guidance.
  • No.

Anything else?

No response

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.