Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(data-warehouse): add Reddit Ads campaign keyword breakdown report (#79826)

jake sciottoa85151766c91
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS.md b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS.md
index e42ffe0fc10a..658309c02c58 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS.md
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS.md
@@ -386,10 +386,10 @@ Diffed against the Reddit Ads v3 OpenAPI spec (`https://ads-api.reddit.com/api/v
Have: campaigns, ad_groups, ads, campaign_report, ad_group_report, ad_report, ad_account,
custom_audiences, saved_audiences, pixels, funding_instruments, lead_gen_forms, profiles,
structured_posts, campaign_country_report, campaign_gender_report, campaign_placement_report,
-campaign_community_report, campaign_os_type_report.
+campaign_community_report, campaign_os_type_report, campaign_keyword_report.
- [x] Creative metadata — `structured_posts`, fanned out over the account's profiles. Reddit hangs creatives off profiles, not off the ad account, and ad rows carry the `post_id` to join on.
-- [x] Breakdown dimensions on the report tables — gender, country, placement, device (`OS_TYPE`) and community, each a campaign-grain report table defaulted to `should_sync_default=False`. Reddit returns breakdowns as extra dimensions on the same `POST /reports` call, capped at three per request, so each dimension is its own table rather than a new param. Age is not shippable: `AGE` is absent from the spec's `breakdowns` enum (it appears only in a stale request example).
+- [x] Breakdown dimensions on the report tables — gender, country, placement, device (`OS_TYPE`), community and keyword, each a campaign-grain report table defaulted to `should_sync_default=False`. Reddit returns breakdowns as extra dimensions on the same `POST /reports` call, capped at three per request, so each dimension is its own table rather than a new param. Age is not shippable: `AGE` is absent from the spec's `breakdowns` enum (it appears only in a stale request example). `KEYWORD` is requested as a breakdown only: its membership of the `fields` enum was not re-checked against the spec.
- [x] Ad account table — `ad_account`, carrying `currency` and `time_zone_id`.
- [x] Audiences and pixel definitions — `custom_audiences`, `saved_audiences`, `pixels`. Conversion _events_ are write-only (`POST /pixels/{id}/conversion_events`), so there is nothing to sync.
- Also added: `funding_instruments` (per-instrument currency and credit limit), `lead_gen_forms`, `profiles`.
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/reddit_ads/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/reddit_ads/canonical_descriptions.py
index 20f165184ab9..ff376a8d25e3 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/reddit_ads/canonical_descriptions.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/reddit_ads/canonical_descriptions.py
@@ -295,4 +295,13 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"os_type": "The device operating system type.",
},
},
+ "campaign_keyword_report": {
+ "description": "Daily campaign performance metrics broken down by the keyword the ad was matched on.",
+ "docs_url": "https://ads-api.reddit.com/docs/v3/operations/Generate%20Report",
+ "columns": {
+ **_REPORT_COLUMNS,
+ "campaign_id": "ID of the campaign the metrics are aggregated for.",
+ "keyword": "The targeted keyword the impression was matched on.",
+ },
+ },
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/reddit_ads/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/reddit_ads/settings.py
index dcea4132a289..5725c404ea8b 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/reddit_ads/settings.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/reddit_ads/settings.py
@@ -507,6 +507,15 @@ REDDIT_ADS_CONFIG: dict[str, EndpointConfig] = {
# for it as a field would be rejected. The response carries `os_type` from the breakdown.
breakdown_is_requestable_field=False,
),
+ "campaign_keyword_report": _breakdown_report_endpoint(
+ "campaign_keyword_report",
+ "KEYWORD",
+ "keyword",
+ # Requested as a breakdown only, because whether `KEYWORD` is a member of the report `fields`
+ # enum has not been confirmed against the v3 spec. Sending a field Reddit does not accept
+ # fails the whole report request, so this takes the conservative side of that unknown.
+ breakdown_is_requestable_field=False,
+ ),
}
# Endpoints that are not reachable from the ad account directly and have to be walked from a parent
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/reddit_ads/tests/test_reddit_ads.py b/products/warehouse_sources/backend/temporal/data_imports/sources/reddit_ads/tests/test_reddit_ads.py
index e86d36a7a15f..ebef71fb339c 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/reddit_ads/tests/test_reddit_ads.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/reddit_ads/tests/test_reddit_ads.py
@@ -160,6 +160,7 @@ class TestBreakdownReportEndpoints:
("campaign_placement_report", "PLACEMENT", "placement"),
("campaign_community_report", "COMMUNITY", "community"),
("campaign_os_type_report", "OS_TYPE", "os_type"),
+ ("campaign_keyword_report", "KEYWORD", "keyword"),
]
@parameterized.expand(BREAKDOWN_TABLES)
@@ -190,6 +191,9 @@ class TestBreakdownReportEndpoints:
# `OS_TYPE` is a valid breakdown but is not a member of Reddit's `fields` enum — asking for
# it as a field is rejected and fails the whole report request.
("campaign_os_type_report", "OS_TYPE", False),
+ # `KEYWORD`'s membership of the `fields` enum is unconfirmed, so it is requested as a
+ # breakdown only rather than risking a rejected report request.
+ ("campaign_keyword_report", "KEYWORD", False),
]
)
def test_dimension_is_requested_as_a_field_only_when_reddit_allows_it(
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/reddit_ads/tests/test_reddit_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/reddit_ads/tests/test_reddit_source.py
index 278eacc2e153..c7f70565de9f 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/reddit_ads/tests/test_reddit_source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/reddit_ads/tests/test_reddit_source.py
@@ -273,6 +273,7 @@ class TestRedditAdsSource:
("campaign_placement_report", False),
("campaign_community_report", False),
("campaign_os_type_report", False),
+ ("campaign_keyword_report", False),
],
)
def test_expensive_breakdown_reports_are_not_selected_by_default(self, endpoint, should_sync_default):