Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/add conversions #43

Merged
merged 46 commits into from
Nov 14, 2024
Merged

Feature/add conversions #43

merged 46 commits into from
Nov 14, 2024

Conversation

fivetran-jamie
Copy link
Contributor

@fivetran-jamie fivetran-jamie commented May 21, 2024

PR Overview

This PR will address the following Issue/Feature:
no issue made for conversions + #42

This PR will result in the following new package version:

v0.8.0

Please provide the finalized CHANGELOG entry which details the relevant changes included in this PR:

Feature Updates

Introducing...conversion metrics (PR #43)!

  • Adds a conversion_value field to each _report end model, representing the value of conversions (calculated using the default attribution window set in Meta) that occurred on each day for each ad/campaign/ad set/url/account.
  • Creates a facebook_ads__basic_ad_actions_passthrough_metrics variable to pass through additional conversion value metrics that are calculated using different attribution windows.
    • By default, the package includes only the conversion value calculated using the default attribution window, but your report may include calculations using the other windows defined here. See README for details on how to use the new var.

Documentation

  • Documents the ability to transform metrics provided to the facebook_ads__basic_ad_passthrough_metrics variable. See README for details (PR #43).

Under the Hood

  • Updated the quickstart.yml file to allow for automated Quickstart data model deployments (PR #40).
  • Updated the PR templates to align with our most up-to-date standards (PR #43).

PR Checklist

Basic Validation

Please acknowledge that you have successfully performed the following commands locally:

  • dbt run –full-refresh && dbt test
  • dbt run (if incremental models are present)

Before marking this PR as "ready for review" the following have been applied:

  • The appropriate issue has been linked, tagged, and properly assigned
  • All necessary documentation and version upgrades have been applied
  • docs were regenerated (unless this PR does not include any code or yml updates)
  • BuildKite integration tests are passing
  • Detailed validation steps have been provided below

Detailed Validation

Please share any and all of your validation steps:

Tests are passing
image

  1. Horizontal integrity test compares total sum of conversion_value from each _report end model
  2. Consistency tests compare clicks, impressions, and spend across dev and prod in each of the _report models

No exceptions needed, just a teeny tiny buffer to account for differences in rounding
image

Copy link
Contributor

@fivetran-joemarkiewicz fivetran-joemarkiewicz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fivetran-jamie these changes look great! I just have a few minor suggestions, but none related to the actual code. I see this being a huge value add for our users!

Once you address the comments in this review let's hold off merging until the other updates in the Google and LinkedIn packages are ready as well. Thanks and great job!

integration_tests/dbt_project.yml Show resolved Hide resolved
packages.yml Outdated
Comment on lines 2 to 7
# - package: fivetran/facebook_ads_source
# version: [">=0.8.0", "<0.9.0"]
# - local: ../Facebook_ads/dbt_facebook_ads_source
- git: https://github.com/fivetran/dbt_facebook_ads_source.git
revision: feature/add-conversions
warn-unpinned: false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reminder to swap before merge

{{ fivetran_utils.persist_pass_through_columns(pass_through_variable='facebook_ads__basic_ad_passthrough_metrics', transform = 'sum') }}
, sum(coalesce(conversion_report.conversion_value, 0)) as conversion_value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to confirm, should 0 and null be represented the same here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, though i have actually yet to see a null (or even 0) conversion value recorded in basic_ad_actions

the individual/passthrough values are null when representing 0 however
image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for confirming. Good to see we haven't seen null in the conversion value, but great to see we are being proactive with this logic. This looks good to me!

models/facebook_ads__account_report.sql Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
CHANGELOG.md Show resolved Hide resolved
@fivetran-data-model-bot fivetran-data-model-bot requested review from a team, fivetran-reneeli and fivetran-catfritz and removed request for a team May 23, 2024 18:44
@fivetran-catfritz
Copy link
Contributor

@fivetran-jamie @fivetran-joemarkiewicz Now might be a good time to delete the defunct 2nd reviewer bot.

@fivetran-joemarkiewicz
Copy link
Contributor

@fivetran-jamie @fivetran-joemarkiewicz Now might be a good time to delete the defunct 2nd reviewer bot.

Agreed! @fivetran-jamie would you be able to remove that from this branch.

fivetran-jamie and others added 5 commits May 23, 2024 13:21
Co-authored-by: Joe Markiewicz <74217849+fivetran-joemarkiewicz@users.noreply.github.com>
Co-authored-by: Joe Markiewicz <74217849+fivetran-joemarkiewicz@users.noreply.github.com>
@maxtuzz
Copy link

maxtuzz commented May 28, 2024

Great effort! Looking forward to this release.

Copy link
Contributor

@fivetran-joemarkiewicz fivetran-joemarkiewicz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fivetran-jamie great work on this PR and you're nearly there to releasing full support for conversions in our ad reporting packages!!

I have a few comments and suggestions in line. Additionally, I noticed I ran into a similar error from before where I run into an issue when trying to passthrough a default conversion value from this PR into the facebook_ads__basic_ad_passthrough_metrics variable. Would you be able to look into this and confirm if this is intentional or if there are some adjustments we need to make to this logic within the models.

image

Thanks!

docs/run_results.json Outdated Show resolved Hide resolved
packages.yml Outdated
Comment on lines 2 to 8
# - package: fivetran/facebook_ads_source
# version: [">=0.8.0", "<0.9.0"]
# - local: ../Facebook_ads/dbt_facebook_ads_source
# - local: ../../dbt_facebook_ads_source
- git: https://github.com/fivetran/dbt_facebook_ads_source.git
revision: feature/add-conversions
warn-unpinned: false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reminder to clean and swap before merge

@fivetran-jamie
Copy link
Contributor Author

I noticed I ran into a similar error from before where I run into an issue when trying to passthrough a default conversion value from this PR into the facebook_ads__basic_ad_passthrough_metrics variable. Would you be able to look into this and confirm if this is intentional or if there are some adjustments we need to make to this logic within the models.

@fivetran-joemarkiewicz Yeah this is the expected behavior, as conversions are explicitly not included in basic_ad according to our docs. However, I suppose there is nothing stopping someone from adding conversions as a passthrough field, even if null (especially if they were using passthrough columns to add conversions to the ad_reporting models).

To avoid duplicate column errors, we can employ the same _c suffix method as ad_reporting, or we can just choose to select our version of conversions since any previous field was likely null

@fivetran-jamie fivetran-jamie added status:in_progress Currently being worked on and removed status:blocked Need additional information or requirements before proceeding labels Nov 6, 2024
@fivetran-joemarkiewicz
Copy link
Contributor

conversions are explicitly not included in basic_ad according to our docs.

Thanks for calling this out @fivetran-jamie! I was going through and stress testing so I see how I tested something that realistically should never occur. I would recommend if the conversion fields should not exist in the BASIC_AD table, then I feel comfortable giving our default value the preference and not including the _c field name as it will most likely be null.

Thanks for clarifying this!

Copy link
Contributor

@fivetran-joemarkiewicz fivetran-joemarkiewicz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Contributor

@fivetran-reneeli fivetran-reneeli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just had some questions!

CHANGELOG.md Outdated Show resolved Hide resolved
README.md Outdated
@@ -89,19 +93,62 @@ vars:
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.

#### Passing Through Additional Metrics
By default, this package will select `clicks`, `impressions`, and `cost` from the source reporting tables to store into the staging models. If you would like to pass through additional metrics to the staging models, add the below configurations to your `dbt_project.yml` file. These variables allow for the pass-through fields to be aliased (`alias`) if desired, but not required. Use the below format for declaring the respective pass-through variables:
By default, this package will select `clicks`, `impressions`, `cost`, and conversion `value` (using the default attribution window) from the source reporting tables (`BASIC_AD`, `BASIC_AD_ACTIONS`, and `BASIC_AD_ACTION_VALUES`) to store into the output models. If you would like to pass through additional metrics to the output models, add the below configurations to your `dbt_project.yml` file. These variables allow for the pass-through fields to be aliased (`alias`) and transformed (`transform_sql`) if desired, but not required. Only the `name` of each metric field is required. Use the below format for declaring the respective pass-through variables:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also stating what the default is here?

README.md Outdated Show resolved Hide resolved
from report
left join conversion_report
on report.date_day = conversion_report.date_day
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to join by source_relation here as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jeez I can't believe I forgot these, good catch

from report
left join conversion_report
on report.date_day = conversion_report.date_day
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

source_relation join?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doh!

fivetran-jamie and others added 3 commits November 12, 2024 15:52
Co-authored-by: Renee Li <91097070+fivetran-reneeli@users.noreply.github.com>
Copy link
Contributor

@fivetran-reneeli fivetran-reneeli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@fivetran-data-model-bot fivetran-data-model-bot requested review from a team and fivetran-avinash and removed request for a team November 13, 2024 15:30
@fivetran-jamie fivetran-jamie merged commit 6c67bba into main Nov 14, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:in_progress Currently being worked on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants