{"id":22793274,"url":"https://github.com/fivetran/dbt_klaviyo","last_synced_at":"2026-02-13T02:04:34.273Z","repository":{"id":42654247,"uuid":"351613324","full_name":"fivetran/dbt_klaviyo","owner":"fivetran","description":null,"archived":false,"fork":false,"pushed_at":"2025-01-22T20:57:51.000Z","size":2709,"stargazers_count":5,"open_issues_count":3,"forks_count":5,"subscribers_count":41,"default_branch":"main","last_synced_at":"2025-03-29T05:33:43.083Z","etag":null,"topics":["dbt","dbt-packages","fivetran","klaviyo"],"latest_commit_sha":null,"homepage":"https://fivetran.github.io/dbt_klaviyo/","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fivetran.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-26T00:21:34.000Z","updated_at":"2025-01-22T20:57:52.000Z","dependencies_parsed_at":"2023-10-14T17:57:08.815Z","dependency_job_id":"d50db840-7a7b-4c1c-b5c0-5400a9788afe","html_url":"https://github.com/fivetran/dbt_klaviyo","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fivetran%2Fdbt_klaviyo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fivetran%2Fdbt_klaviyo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fivetran%2Fdbt_klaviyo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fivetran%2Fdbt_klaviyo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fivetran","download_url":"https://codeload.github.com/fivetran/dbt_klaviyo/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249266492,"owners_count":21240765,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dbt","dbt-packages","fivetran","klaviyo"],"created_at":"2024-12-12T03:18:58.497Z","updated_at":"2026-02-13T02:04:34.267Z","avatar_url":"https://github.com/fivetran.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!--section=\"klaviyo_transformation_model\"--\u003e\n# Klaviyo dbt Package\n\n\u003cp align=\"left\"\u003e\n    \u003ca alt=\"License\"\n        href=\"https://github.com/fivetran/dbt_klaviyo/blob/main/LICENSE\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/License-Apache%202.0-blue.svg\" /\u003e\u003c/a\u003e\n    \u003ca alt=\"dbt-core\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/dbt_Core™_version-\u003e=1.3.0,_\u003c3.0.0-orange.svg\" /\u003e\u003c/a\u003e\n    \u003ca alt=\"Maintained?\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/Maintained%3F-yes-green.svg\" /\u003e\u003c/a\u003e\n    \u003ca alt=\"PRs\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/Contributions-welcome-blueviolet\" /\u003e\u003c/a\u003e\n    \u003ca alt=\"Fivetran Quickstart Compatible\"\n        href=\"https://fivetran.com/docs/transformations/data-models/quickstart-management#quickstartmanagement\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/Fivetran_Quickstart_Compatible%3F-yes-green.svg\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\nThis dbt package transforms data from Fivetran's Klaviyo connector into analytics-ready tables.\n\n## Resources\n\n- Number of materialized models¹: 18\n- Connector documentation\n  - [Klaviyo connector documentation](https://fivetran.com/docs/connectors/applications/klaviyo)\n  - [Klaviyo ERD](https://fivetran.com/docs/connectors/applications/klaviyo#schemainformation)\n- dbt package documentation\n  - [GitHub repository](https://github.com/fivetran/dbt_klaviyo)\n  - [dbt Docs](https://fivetran.github.io/dbt_klaviyo/#!/overview)\n  - [DAG](https://fivetran.github.io/dbt_klaviyo/#!/overview?g_v=1)\n  - [Changelog](https://github.com/fivetran/dbt_klaviyo/blob/main/CHANGELOG.md)\n\n## What does this dbt package do?\nThis package enables you to better understand the efficacy of your email and SMS marketing efforts. It creates enriched models with metrics focused on last-touch attribution, user interactions, and revenue attribution.\n\n### Output schema\nFinal output tables are generated in the following target schema:\n\n```\n\u003cyour_database\u003e.\u003cconnector/schema_name\u003e_klaviyo\n```\n\n### Final output tables\n\nBy default, this package materializes the following final tables:\n\n| Table | Description |\n| :---- | :---- |\n| [klaviyo__events](https://fivetran.github.io/dbt_klaviyo/#!/model/model.klaviyo.klaviyo__events) | Tracks all customer events with customizable last-touch attribution connecting events to email campaigns and flows, plus user information to analyze engagement and conversion paths. \u003cbr\u003e\u003c/br\u003e**Example Analytics Questions:**\u003cul\u003e\u003cli\u003eWhich customer actions are driving the most sales?\u003c/li\u003e\u003cli\u003eAre one-time email campaigns or automated email flows generating more revenue?\u003c/li\u003e\u003cli\u003eHow quickly do customers purchase after engaging with an email?\u003c/li\u003e\u003c/ul\u003e|\n| [klaviyo__person_campaign_flow](https://fivetran.github.io/dbt_klaviyo/#!/model/model.klaviyo.klaviyo__person_campaign_flow) | Aggregates person-level engagement with specific campaigns or flows including total attributed revenue and conversion event counts to measure marketing effectiveness at the individual level. \u003cbr\u003e\u003c/br\u003e**Example Analytics Questions:**\u003cul\u003e\u003cli\u003eWhich customers and campaigns are your best revenue drivers?\u003c/li\u003e\u003cli\u003eHow many purchases does each customer make after engaging with specific campaigns or flows?\u003c/li\u003e\u003cli\u003eWhat's the average revenue per customer for each of your email campaigns and automated flows?\u003c/li\u003e\u003c/ul\u003e|\n| [klaviyo__campaigns](https://fivetran.github.io/dbt_klaviyo/#!/model/model.klaviyo.klaviyo__campaigns) | Summarizes campaign performance with user interaction metrics including opens, clicks, bounces, and attributed revenue to evaluate email campaign effectiveness. \u003cbr\u003e\u003c/br\u003e**Example Analytics Questions:**\u003cul\u003e\u003cli\u003eWhich email campaigns are generating the most opens, clicks, and revenue?\u003c/li\u003e\u003cli\u003eDo higher email open and click rates actually lead to more sales?\u003c/li\u003e\u003cli\u003eWhat's the return on investment for each campaign based on revenue per recipient?\u003c/li\u003e\u003c/ul\u003e|\n| [klaviyo__flows](https://fivetran.github.io/dbt_klaviyo/#!/model/model.klaviyo.klaviyo__flows) | Tracks automated flow performance with user interaction metrics and attributed revenue to understand how email automation drives engagement and conversions. \u003cbr\u003e\u003c/br\u003e**Example Analytics Questions:**\u003cul\u003e\u003cli\u003eWhich automated email flows are bringing in the most revenue and engagement?\u003c/li\u003e\u003cli\u003eAre welcome series or cart abandonment flows performing better?\u003c/li\u003e\u003cli\u003eWhat's the average revenue per customer for each automated flow?\u003c/li\u003e\u003c/ul\u003e|\n| [klaviyo__persons](https://fivetran.github.io/dbt_klaviyo/#!/model/model.klaviyo.klaviyo__persons) | Provides a complete view of each customer with lifetime engagement metrics across campaigns and flows, attributed and organic revenue, and recent activity patterns. \u003cbr\u003e\u003c/br\u003e**Example Analytics Questions:**\u003cul\u003e\u003cli\u003eWho are your highest-value customers and how engaged are they with your emails?\u003c/li\u003e\u003cli\u003eHow much revenue comes from email marketing versus customers purchasing organically?\u003c/li\u003e\u003cli\u003eHow many email campaigns and flows does the average customer interact with?\u003c/li\u003e\u003c/ul\u003e|\n\n¹ Each Quickstart transformation job run materializes these 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`.\n\n---\n\n## Prerequisites\nTo use this dbt package, you must have the following:\n\n- At least one Fivetran Klaviyo connection syncing data into your destination.\n- A **BigQuery**, **Snowflake**, **Redshift**, **PostgreSQL**, or **Databricks** destination.\n\n## How do I use the dbt package?\nYou can either add this dbt package in the Fivetran dashboard or import it into your dbt project:\n\n- To add the package in the Fivetran dashboard, follow our [Quickstart guide](https://fivetran.com/docs/transformations/data-models/quickstart-management).\n- To add the package to your dbt project, follow the setup instructions in the dbt package's [README file](https://github.com/fivetran/dbt_klaviyo/blob/main/README.md#how-do-i-use-the-dbt-package) to use this package.\n\n\u003c!--section-end--\u003e\n\n### Install the package\nInclude the following klaviyo package version in your `packages.yml` file:\n\u003e 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.\n```yaml\npackages:\n  - package: fivetran/klaviyo\n    version: [\"\u003e=1.3.0\", \"\u003c1.4.0\"]\n```\n\n\u003e All required sources and staging models are now bundled into this transformation package. Do not include `fivetran/klaviyo_source` in your `packages.yml` since this package has been deprecated.\n\n#### Databricks Dispatch Configuration\nIf 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.\n```yml\ndispatch:\n  - macro_namespace: dbt_utils\n    search_order: ['spark_utils', 'dbt_utils']\n```\n\n### Define database and schema variables\nBy default, this package runs using your destination and the `klaviyo` schema. If this is not where your Klaviyo data is (for example, if your Klaviyo schema is named `klaviyo_fivetran`), add the following configuration to your root `dbt_project.yml` file:\n\n```yml\nvars:\n  klaviyo_database: your_database_name\n  klaviyo_schema: your_schema_name\n```\n\n### (Optional) Additional configurations\n\u003cdetails open\u003e\u003csummary\u003eExpand/Collapse details\u003c/summary\u003e\n\n#### Unioning Multiple Klaviyo Connections\nIf you have multiple Klaviyo 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 (**note that you cannot use both**) the `klaviyo_union_schemas` or `klaviyo_union_databases` variables:\n\n```yml\n# dbt_project.yml\n...\nconfig-version: 2\nvars:\n  klaviyo:\n    klaviyo_union_schemas: ['klaviyo_usa','klaviyo_canada'] # use this if the data is in different schemas/datasets of the same database/project\n    klaviyo_union_databases: ['klaviyo_usa','klaviyo_canada'] # use this if the data is in different databases/projects but uses the same schema name\n```\n\n#### Event Attribution\n\nIf available, the package uses Klaviyo's native `property_attribution` field from the EVENT source for attributing events to campaigns and flows. This approach ensures consistency with Klaviyo's platform and provides the most accurate attribution data.\n\n**Primary Attribution Method:**\n- Uses Klaviyo's built-in `property_attribution` field when available\n- Events inherit attribution from parent events via `attributed_event_id` references\n- Aligns with Klaviyo's internal [attribution model](https://help.klaviyo.com/hc/en-us/articles/115005248128)\n- No additional configuration required\n\n**Session-Based Attribution Fallback:**\nFor users who need custom attribution logic or are migrating from older package versions, an optional session-based attribution method is available. This method is disabled by default if your EVENT source contains the `property_attribution` field but can be enabled by setting `using_native_attribution: false`. **If you do not have the `property_attribution` field, this method will be used by default.**\n\nWhen enabled, this method uses configurable lookback windows:\n- **120 hours (5 days)** for email events  \n- **24 hours** for SMS events\n\n```yml\n# dbt_project.yml\nvars:\n  klaviyo:\n    using_native_attribution: false # Disable native attribution to use session-based fallback\n    klaviyo__email_attribution_lookback: 120 # Hours for email attribution\n    klaviyo__sms_attribution_lookback: 24 # Hours for SMS attribution\n```\n\n\u003e **Note:** For detailed information about attribution methods and when to use each approach, see the [DECISIONLOG.md](https://github.com/fivetran/dbt_klaviyo/blob/main/DECISIONLOG.md).\n\n\u003e Events already associated with campaigns or flows in Klaviyo will never have their source attribution data overwritten by the package modeling.\n\n##### Attribution-Eligible Event Types (Session-Based Fallback Only)\n\n\u003e **Note:** This configuration only applies when session-based attribution is used. The primary attribution method uses Klaviyo's native attribution without additional filtering.\n\nWhen using the session-based attribution fallback, the package will only credit email opens, email clicks, and SMS opens with conversions by default. This filter determines which event types can trigger new attribution sessions and is aligned with Klaviyo's internal [attribution model](https://help.klaviyo.com/hc/en-us/articles/115005248128).\n\nTo customize which events can qualify for attribution in the session-based method, add the following configuration to your `dbt_project.yml` file:\n\n```yml\n# dbt_project.yml\n\n...\nconfig-version: 2\n\nvars:\n  klaviyo:\n    klaviyo__eligible_attribution_events: ['types', 'of', 'events', 'to', 'attribute', 'conversions', 'to'] # this is case-SENSITIVE and should be in all lower-case!!\n```\n\n#### Filtering Conversion Metrics to Pivot Out\n\nThe Klaviyo dbt package pivots relevant conversion events out into metric columns in the `klaviyo__person_campaign_flow`, `klaviyo__campaigns`, `klaviyo__flows`, and `klaviyo__persons` models. The package will sum up revenue attributed to each person's interactions with flows and campaigns (plus organic actions), count the instances of each kind of triggered conversion, and, at the flow and campaign grain, count the number of unique people who converted. The package splits up events to pivot out into two variables, `klaviyo__count_metrics` and `klaviyo__sum_revenue_metrics`, which will record the count of events/users and their associated revenue values, respectively.\n\nBy default, the package is configured to pivot out the below metrics. To change the conversion events that are pivoted out, tailor the following configuration to your desired metrics in your `dbt_project.yml` file:\n\n```yml\n# dbt_project.yml\n\n...\nconfig-version: 2\n\nvars:\n  klaviyo: # case insensitive \n    klaviyo__count_metrics: \n      - 'Active on Site'\n      - 'Viewed Product'\n      - 'Ordered Product'\n      - 'Placed Order'\n      - 'Refunded Order'\n      - 'Received Email'\n      - 'Clicked Email'\n      - 'Opened Email'\n      - 'Marked Email as Spam'\n      - 'Unsubscribed'\n      - 'Received SMS'\n      - 'Clicked SMS'\n      - 'Sent SMS'\n      - 'Unsubscribed from SMS'\n\n    klaviyo__sum_revenue_metrics:\n      - 'Refunded Order'\n      - 'Placed Order'\n      - 'Ordered Product'\n      - 'checkout started'\n      - 'cancelled order'\n```\n\n#### Passthrough Columns\n\nAdditionally, the Klaviyo package includes all source columns defined in the [macros folder](https://github.com/fivetran/dbt_klaviyo/tree/main/macros) of the source package. We highly recommend including custom fields in this package as models now only bring in the standard fields for the `EVENT` and `PERSON` tables.\n\nYou can add more columns using our passthrough column variables. These variables allow for the passthrough fields to be aliased (`alias`) and casted (`transform_sql`) if desired, although it is not required. Datatype casting is configured via a SQL snippet within the `transform_sql` key. You may add the desired SQL snippet while omitting the `as field_name` part of the casting statement - this will be dealt with by the alias attribute - and your custom passthrough fields will be casted accordingly.\n\nUse the following format for declaring the respective passthrough variables:\n\n```yml\n# dbt_project.yml\n\n...\nvars:\n  klaviyo__event_pass_through_columns: \n    - name:           \"property_field_id\"\n      alias:          \"new_name_for_this_field_id\"\n      transform_sql:  \"cast(new_name_for_this_field as int64)\"\n    - name:           \"this_other_field\"\n      transform_sql:  \"cast(this_other_field as string)\"\n  klaviyo__person_pass_through_columns:\n    - name:           \"custom_crazy_field_name\"\n      alias:          \"normal_field_name\"\n```\n\n#### Changing the Build Schema\n\nBy default, this package will build the Klaviyo final models within a schema titled (`\u003ctarget_schema\u003e` + `_klaviyo`), intermediate models in (`\u003ctarget_schema\u003e` + `_int_klaviyo`), and staging models within a schema titled (`\u003ctarget_schema\u003e` + `_stg_klaviyo`) in your target database. If this is not where you would like your modeled Klaviyo data to be written to, add the following configuration to your `dbt_project.yml` file:\n\n```yml\n# dbt_project.yml\n\n...\nmodels:\n    klaviyo:\n      +schema: my_new_schema_name # Leave +schema: blank to use the default target_schema.\n      staging:\n        +schema: my_new_schema_name # Leave +schema: blank to use the default target_schema.\n```\n\n\u003e Note that if your profile does not have permissions to create schemas in your warehouse, you can set each `+schema` to blank. The package will then write all tables to your pre-existing target schema.\n\n#### Change the source table references\nIf 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:\n\n\u003e IMPORTANT: See this project's [`dbt_project.yml`](https://github.com/fivetran/dbt_klaviyo/blob/main/dbt_project.yml) variable declarations to see the expected names.\n\n```yml\nvars:\n    klaviyo_\u003cdefault_source_table_name\u003e_identifier: your_table_name \n```\n\n\u003c/details\u003e\n\n### (Optional) Orchestrate your models with Fivetran Transformations for dbt Core™\n\u003cdetails\u003e\u003csummary\u003eExpand for more details\u003c/summary\u003e\n\nFivetran offers the ability for you to orchestrate your dbt project through [Fivetran Transformations for dbt Core™](https://fivetran.com/docs/transformations/dbt#transformationsfordbtcore). 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/setup-guide#transformationsfordbtcoresetupguide).\n\n\u003c/details\u003e\n\n## Does this package have dependencies?\nThis 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.\n\u003e 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.\n\n```yml\npackages:\n    - package: fivetran/fivetran_utils\n      version: [\"\u003e=0.4.0\", \"\u003c0.5.0\"]\n\n    - package: dbt-labs/dbt_utils\n      version: [\"\u003e=1.0.0\", \"\u003c2.0.0\"]\n\n    - package: dbt-labs/spark_utils\n      version: [\"\u003e=0.3.0\", \"\u003c0.4.0\"]\n```\n\n\u003c!--section=\"klaviyo_maintenance\"--\u003e\n## How is this package maintained and can I contribute?\n\n### Package Maintenance\nThe Fivetran team maintaining this package only maintains the [latest version](https://hub.getdbt.com/fivetran/klaviyo/latest/) of the package. We highly recommend you stay consistent with the latest version of the package and refer to the [CHANGELOG](https://github.com/fivetran/dbt_klaviyo/blob/main/CHANGELOG.md) and release notes for more information on changes across versions.\n\n### Contributions\nA small team of analytics engineers at Fivetran develops these dbt packages. However, the packages are made better by community contributions.\n\nWe highly encourage and welcome contributions to this package. Learn how to contribute to a package in dbt's [Contributing to an external dbt package article](https://discourse.getdbt.com/t/contributing-to-a-dbt-package/657).\n\n\u003c!--section-end--\u003e\n\n## Are there any resources available?\n- If you have questions or want to reach out for help, see the [GitHub Issue](https://github.com/fivetran/dbt_klaviyo/issues/new/choose) section to find the right avenue of support for you.\n- 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).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffivetran%2Fdbt_klaviyo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffivetran%2Fdbt_klaviyo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffivetran%2Fdbt_klaviyo/lists"}