: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(warehouse_sources): add Google Ads customer, criterion and conversion-action tables (#79887)
posthog[bot]ae5856c81b22
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.mdindex 2163a7825e41..3141811ce889 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@@ -168,7 +168,7 @@ Lower priority: `issuing/*`, `treasury/*`, `terminal/*`, `identity/*`, `financiaDiffed against the [Google Ads API v25 field reference](https://developers.google.com/google-ads/api/fields/v25/overview)on 2026-08-04, using each resource's attributed/segmenting resource lists and the per-field"selectable with" lists to check every field, segment and metric combination.-35 tables and the best-covered source we have.+40 tables and the best-covered source we have.- [x] `campaign_budget` — budgets and budget pacing.- [x] `age_range_view`, `gender_view` — demographic breakdowns.@@ -185,7 +185,14 @@ on 2026-08-04, using each resource's attributed/segmenting resource lists and th`ad_group_ad_asset_view` or `asset_field_type_view` and is still open.- [x] Hourly segmentation, as `campaign_hourly_stats`. (device segmentation was already there — everyexisting `*_stats` table selects `segments.device`)-- [x] Conversion stats segmented by `conversion_action` (we have the actions but not their stats).+- [x] Conversion stats segmented by `conversion_action`, at campaign, ad group and keyword level+ (`campaign_conversion_action_stats`, `ad_group_conversion_action_stats`,+ `keyword_conversion_action_stats`). All off by default — the per-action fan-out multiplies rows.+- [x] `customer` — account entity table (timezone, currency, auto-tagging, manager status, conversion+ tracking), distinct from the daily `customer_stats` fact table.+- [x] `ad_group_criterion`, `campaign_criterion` — every targeting criterion including negative keywords+ and other exclusions. The `keyword` table is backed by `keyword_view`, which by API design only+ returns positive, servable keywords, so negatives were previously unreachable. Both off by default.### Meta Ads — spec-verifieddiff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/google_ads/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/google_ads/canonical_descriptions.pyindex b1255f245946..e5513556f1f3 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/google_ads/canonical_descriptions.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/google_ads/canonical_descriptions.py@@ -173,6 +173,55 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"ad_group_criterion_position_estimates_first_position_cpc_micros": "Estimated CPC bid, in micros, required to show the ad in the first position.",},},+ "ad_group_criterion": {+ "description": "Every targeting criterion at ad group level, including negative keywords and other exclusions. Unlike the keyword table, this reaches negative and non-keyword criteria.",+ "docs_url": "https://developers.google.com/google-ads/api/fields/v25/ad_group_criterion",+ "columns": {+ **_IDS,+ "ad_group_criterion_criterion_id": "Unique ID of the criterion.",+ "ad_group_criterion_type": "Type of the criterion (e.g. keyword, placement, age range, user list).",+ "ad_group_criterion_status": "Status of the criterion (enabled, paused, or removed).",+ "ad_group_criterion_negative": "Whether the criterion is a negative (exclusion) rather than a target.",+ "ad_group_criterion_system_serving_status": "System-determined serving status of the criterion.",+ "ad_group_criterion_approval_status": "Approval status of the criterion.",+ "ad_group_criterion_display_name": "Display name of the criterion.",+ "ad_group_criterion_bid_modifier": "Bid modifier applied to the criterion.",+ "ad_group_criterion_cpc_bid_micros": "Cost-per-click bid on the criterion, in micros.",+ "ad_group_criterion_effective_cpc_bid_micros": "Effective cost-per-click bid, in micros, after inheritance.",+ "ad_group_criterion_keyword_text": "Keyword text, when the criterion is a keyword.",+ "ad_group_criterion_keyword_match_type": "Keyword match type (exact, phrase, or broad), when the criterion is a keyword.",+ "ad_group_criterion_placement_url": "Placement URL, when the criterion is a placement.",+ "ad_group_criterion_age_range_type": "Age range bucket, when the criterion is an age range.",+ "ad_group_criterion_gender_type": "Gender, when the criterion is a gender.",+ "ad_group_criterion_topic_topic_constant": "Topic constant, when the criterion is a topic.",+ "ad_group_criterion_user_list_user_list": "Resource name of the user list, when the criterion is a user list.",+ "ad_group_criterion_final_urls": "Final landing page URLs for the criterion.",+ "ad_group_criterion_tracking_url_template": "URL template for constructing tracking URLs for the criterion.",+ },+ },+ "campaign_criterion": {+ "description": "Every targeting criterion at campaign level, including negative keywords, excluded locations, languages, devices and other exclusions.",+ "docs_url": "https://developers.google.com/google-ads/api/fields/v25/campaign_criterion",+ "columns": {+ "customer_id": "The Google Ads customer (account) ID the row belongs to.",+ "campaign_id": "The campaign ID the row belongs to.",+ "campaign_criterion_criterion_id": "Unique ID of the criterion.",+ "campaign_criterion_type": "Type of the criterion (e.g. keyword, location, language, device).",+ "campaign_criterion_status": "Status of the criterion (enabled, paused, or removed).",+ "campaign_criterion_negative": "Whether the criterion is a negative (exclusion) rather than a target.",+ "campaign_criterion_bid_modifier": "Bid modifier applied to the criterion.",+ "campaign_criterion_display_name": "Display name of the criterion.",+ "campaign_criterion_keyword_text": "Keyword text, when the criterion is a keyword.",+ "campaign_criterion_keyword_match_type": "Keyword match type (exact, phrase, or broad), when the criterion is a keyword.",+ "campaign_criterion_location_geo_target_constant": "Resource name of the targeted geo location, when the criterion is a location.",+ "campaign_criterion_language_language_constant": "Resource name of the targeted language, when the criterion is a language.",+ "campaign_criterion_device_type": "Device type, when the criterion is a device.",+ "campaign_criterion_age_range_type": "Age range bucket, when the criterion is an age range.",+ "campaign_criterion_gender_type": "Gender, when the criterion is a gender.",+ "campaign_criterion_placement_url": "Placement URL, when the criterion is a placement.",+ "campaign_criterion_user_list_user_list": "Resource name of the user list, when the criterion is a user list.",+ },+ },"keyword_stats": {"description": "Daily performance metrics for keywords (keyword_view), segmented by date, device, and network.","docs_url": "https://developers.google.com/google-ads/api/fields/v17/keyword_view",@@ -214,6 +263,33 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {metrics_video_quartile_p100_rate="Share of impressions that watched the entire video.",),},+ "customer": {+ "description": "Account-level settings for the Google Ads customer — timezone, currency, auto-tagging, manager status and conversion tracking. One row per account, distinct from the daily metrics in customer_stats.",+ "docs_url": "https://developers.google.com/google-ads/api/fields/v25/customer",+ "columns": {+ "customer_id": "The Google Ads customer (account) ID.",+ "customer_descriptive_name": "Human-readable name of the account.",+ "customer_currency_code": "Three-letter ISO 4217 currency code of the account.",+ "customer_time_zone": "IANA time zone of the account (e.g. America/New_York).",+ "customer_tracking_url_template": "URL template for constructing tracking URLs, applied account-wide.",+ "customer_final_url_suffix": "Query parameters appended to landing page URLs, applied account-wide.",+ "customer_auto_tagging_enabled": "Whether auto-tagging (the gclid URL parameter) is enabled.",+ "customer_has_partners_badge": "Whether the account holds the Google Partners badge.",+ "customer_manager": "Whether the account is a manager (MCC) account.",+ "customer_test_account": "Whether the account is a test account.",+ "customer_status": "Status of the account (enabled, canceled, suspended, or closed).",+ "customer_optimization_score": "Optimization score of the account, from 0 to 1.",+ "customer_optimization_score_weight": "Weight used to combine this account's optimization score into a manager-level score.",+ "customer_pay_per_conversion_eligibility_failure_reasons": "Reasons the account is ineligible for pay-per-conversion billing, if any.",+ "customer_conversion_tracking_setting_conversion_tracking_id": "Conversion tracking ID used for this account's conversions.",+ "customer_conversion_tracking_setting_cross_account_conversion_tracking_id": "Conversion tracking ID of the manager account, when conversion tracking is managed at manager level.",+ "customer_conversion_tracking_setting_accepted_customer_data_terms": "Whether the customer has accepted the customer data terms.",+ "customer_conversion_tracking_setting_conversion_tracking_status": "Conversion tracking status of the account (e.g. not converting, converting with this account, or converting with a manager).",+ "customer_conversion_tracking_setting_enhanced_conversions_for_leads_enabled": "Whether enhanced conversions for leads is enabled.",+ "customer_conversion_tracking_setting_google_ads_conversion_customer": "Resource name of the account that owns the conversions this account reports.",+ "customer_remarketing_setting_google_global_site_tag": "The global site tag snippet for remarketing.",+ },+ },"customer_stats": {"description": "Daily account-level performance totals for the Google Ads customer.","docs_url": "https://developers.google.com/google-ads/api/fields/v17/customer",@@ -553,4 +629,29 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {}),},+ "ad_group_conversion_action_stats": {+ "description": "Daily ad group conversions broken out by conversion action. Only conversion metrics are available alongside this segmentation, so clicks, impressions and cost are not included.",+ "docs_url": "https://developers.google.com/google-ads/api/fields/v25/ad_group",+ "columns": _stats_columns(+ **{+ "segments_conversion_action": "Resource name of the conversion action the conversions are attributed to. Join to conversion_action.",+ "segments_conversion_action_name": "Name of the conversion action.",+ "segments_conversion_action_category": "Category of the conversion action (e.g. purchase, lead, sign-up).",+ "metrics_cross_device_conversions": "Conversions where the conversion happened on a different device to the ad interaction.",+ }+ ),+ },+ "keyword_conversion_action_stats": {+ "description": "Daily keyword conversions broken out by conversion action. Only conversion metrics are available alongside this segmentation, so clicks, impressions and cost are not included.",+ "docs_url": "https://developers.google.com/google-ads/api/fields/v25/keyword_view",+ "columns": _stats_columns(+ **{+ "ad_group_criterion_criterion_id": "Unique ID of the keyword criterion the conversions belong to.",+ "segments_conversion_action": "Resource name of the conversion action the conversions are attributed to. Join to conversion_action.",+ "segments_conversion_action_name": "Name of the conversion action.",+ "segments_conversion_action_category": "Category of the conversion action (e.g. purchase, lead, sign-up).",+ "metrics_cross_device_conversions": "Conversions where the conversion happened on a different device to the ad interaction.",+ }+ ),+ },}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/google_ads/schemas.py b/products/warehouse_sources/backend/temporal/data_imports/sources/google_ads/schemas.pyindex 40ade2c46727..6db881ec3562 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/google_ads/schemas.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/google_ads/schemas.py@@ -603,6 +603,61 @@ RESOURCE_SCHEMAS: dict[str, dict[str, Any]] = {"segments.year",],},+ "ad_group_criterion": {+ "resource_name": "ad_group_criterion",+ "primary_key": ["ad_group_criterion.criterion_id", "ad_group.id", "campaign.id", "customer.id"],+ "should_sync_default": False,+ "description": "Every targeting criterion at ad group level, including negative keywords and other exclusions. Unlike the keyword table (which is backed by keyword_view and only returns positive, servable keywords), this reaches negative and non-keyword criteria. Filter on ad_group_criterion.negative to isolate exclusions.",+ "field_names": [+ "ad_group_criterion.criterion_id",+ "ad_group.id",+ "campaign.id",+ "customer.id",+ "ad_group_criterion.type",+ "ad_group_criterion.status",+ "ad_group_criterion.negative",+ "ad_group_criterion.system_serving_status",+ "ad_group_criterion.approval_status",+ "ad_group_criterion.display_name",+ "ad_group_criterion.bid_modifier",+ "ad_group_criterion.cpc_bid_micros",+ "ad_group_criterion.effective_cpc_bid_micros",+ "ad_group_criterion.keyword.text",+ "ad_group_criterion.keyword.match_type",+ "ad_group_criterion.placement.url",+ "ad_group_criterion.age_range.type",+ "ad_group_criterion.gender.type",+ "ad_group_criterion.topic.topic_constant",+ "ad_group_criterion.user_list.user_list",+ "ad_group_criterion.final_urls",+ "ad_group_criterion.tracking_url_template",+ ],+ },+ "campaign_criterion": {+ "resource_name": "campaign_criterion",+ "primary_key": ["campaign_criterion.criterion_id", "campaign.id", "customer.id"],+ "should_sync_default": False,+ "description": "Every targeting criterion at campaign level, including negative keywords, excluded locations, languages, devices and other exclusions. Filter on campaign_criterion.negative to isolate exclusions.",+ "field_names": [+ "campaign_criterion.criterion_id",+ "campaign.id",+ "customer.id",+ "campaign_criterion.type",+ "campaign_criterion.status",+ "campaign_criterion.negative",+ "campaign_criterion.bid_modifier",+ "campaign_criterion.display_name",+ "campaign_criterion.keyword.text",+ "campaign_criterion.keyword.match_type",+ "campaign_criterion.location.geo_target_constant",+ "campaign_criterion.language.language_constant",+ "campaign_criterion.device.type",+ "campaign_criterion.age_range.type",+ "campaign_criterion.gender.type",+ "campaign_criterion.placement.url",+ "campaign_criterion.user_list.user_list",+ ],+ },"video": {"resource_name": "video","primary_key": ["video.id", "ad_group.id", "campaign.id", "customer.id"],@@ -707,6 +762,34 @@ RESOURCE_SCHEMAS: dict[str, dict[str, Any]] = {"segments.year",],},+ "customer": {+ "resource_name": "customer",+ "primary_key": ["customer.id"],+ "description": "Account-level settings for the Google Ads customer — timezone, currency, auto-tagging, manager status and conversion tracking. One row per account, distinct from the daily metrics in customer_stats.",+ "field_names": [+ "customer.id",+ "customer.descriptive_name",+ "customer.currency_code",+ "customer.time_zone",+ "customer.tracking_url_template",+ "customer.final_url_suffix",+ "customer.auto_tagging_enabled",+ "customer.has_partners_badge",+ "customer.manager",+ "customer.test_account",+ "customer.status",+ "customer.optimization_score",+ "customer.optimization_score_weight",+ "customer.pay_per_conversion_eligibility_failure_reasons",+ "customer.conversion_tracking_setting.conversion_tracking_id",+ "customer.conversion_tracking_setting.cross_account_conversion_tracking_id",+ "customer.conversion_tracking_setting.accepted_customer_data_terms",+ "customer.conversion_tracking_setting.conversion_tracking_status",+ "customer.conversion_tracking_setting.enhanced_conversions_for_leads_enabled",+ "customer.conversion_tracking_setting.google_ads_conversion_customer",+ "customer.remarketing_setting.google_global_site_tag",+ ],+ },"customer_stats": {"resource_name": "customer","primary_key": ["customer.id", "segments.date"],@@ -1374,4 +1457,76 @@ RESOURCE_SCHEMAS: dict[str, dict[str, Any]] = {"segments.year",],},+ "ad_group_conversion_action_stats": {+ "resource_name": "ad_group",+ "primary_key": [+ "ad_group.id",+ "campaign.id",+ "customer.id",+ "segments.conversion_action",+ "segments.date",+ "segments.device",+ ],+ "filter_field_names": [("segments.date", IncrementalFieldType.Date)],+ "should_sync_default": False,+ "description": "This table fans out per conversion action at ad group level, so it only carries conversion metrics — clicks, impressions and cost are not available alongside conversion action segmentation.",+ "field_names": [+ "ad_group.id",+ "campaign.id",+ "customer.id",+ "segments.conversion_action",+ "segments.conversion_action_name",+ "segments.conversion_action_category",+ "segments.date",+ "metrics.conversions",+ "metrics.conversions_value",+ "metrics.all_conversions",+ "metrics.all_conversions_value",+ "metrics.view_through_conversions",+ "metrics.cross_device_conversions",+ "metrics.value_per_conversion",+ "segments.device",+ "segments.month",+ "segments.quarter",+ "segments.week",+ "segments.year",+ ],+ },+ "keyword_conversion_action_stats": {+ "resource_name": "keyword_view",+ "primary_key": [+ "ad_group_criterion.criterion_id",+ "ad_group.id",+ "campaign.id",+ "customer.id",+ "segments.conversion_action",+ "segments.date",+ "segments.device",+ ],+ "filter_field_names": [("segments.date", IncrementalFieldType.Date)],+ "should_sync_default": False,+ "description": "This table fans out per conversion action at keyword level, so it only carries conversion metrics — clicks, impressions and cost are not available alongside conversion action segmentation.",+ "field_names": [+ "ad_group_criterion.criterion_id",+ "ad_group.id",+ "campaign.id",+ "customer.id",+ "segments.conversion_action",+ "segments.conversion_action_name",+ "segments.conversion_action_category",+ "segments.date",+ "metrics.conversions",+ "metrics.conversions_value",+ "metrics.all_conversions",+ "metrics.all_conversions_value",+ "metrics.view_through_conversions",+ "metrics.cross_device_conversions",+ "metrics.value_per_conversion",+ "segments.device",+ "segments.month",+ "segments.quarter",+ "segments.week",+ "segments.year",+ ],+ },}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/google_ads/tests/test_google_ads_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/google_ads/tests/test_google_ads_source.pyindex 4997b9a29d3d..a756171c17c1 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/google_ads/tests/test_google_ads_source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/google_ads/tests/test_google_ads_source.py@@ -1698,17 +1698,41 @@ class TestResourceSchemaInvariants:class TestConversionActionSegmentedStats:- def test_only_conversion_metrics_are_selected(self):+ @pytest.mark.parametrize(+ "alias",+ [+ "campaign_conversion_action_stats",+ "ad_group_conversion_action_stats",+ "keyword_conversion_action_stats",+ ],+ )+ def test_only_conversion_metrics_are_selected(self, alias):# Google rejects a query that pairs segments.conversion_action with a non-conversion metric,# which would fail the whole table rather than drop a column. Keep the metric list to the# conversion family.- field_names = RESOURCE_SCHEMAS["campaign_conversion_action_stats"]["field_names"]+ field_names = RESOURCE_SCHEMAS[alias]["field_names"]metrics = [f for f in field_names if f.startswith("metrics.")]assert metricsassert all("conversion" in metric for metric in metrics)+class TestCriterionTablesReachNegatives:+ # The keyword table is backed by keyword_view, which only ever returns positive, servable+ # keywords. These criterion tables are the only way to reach negative keywords and other+ # exclusions, and that reachability hinges on selecting the `negative` flag — without it the row+ # can't be told apart from a positive target, defeating the table's reason to exist.+ @pytest.mark.parametrize(+ "alias, negative_field",+ [+ ("ad_group_criterion", "ad_group_criterion.negative"),+ ("campaign_criterion", "campaign_criterion.negative"),+ ],+ )+ def test_negative_flag_is_selected(self, alias, negative_field):+ assert negative_field in RESOURCE_SCHEMAS[alias]["field_names"]++class TestBreakdownStatsDefaultOff:# These tables fan a day of spend out across placements, landing pages, product groups, hours and# demographics, so they are orders of magnitude larger than the campaign and ad group reports.@@ -1719,6 +1743,8 @@ class TestBreakdownStatsDefaultOff:["age_range_stats","campaign_conversion_action_stats",+ "ad_group_conversion_action_stats",+ "keyword_conversion_action_stats","campaign_hourly_stats","detail_placement_stats","gender_stats",@@ -1726,6 +1752,8 @@ class TestBreakdownStatsDefaultOff:"location_stats","product_group_stats","user_location_stats",+ "ad_group_criterion",+ "campaign_criterion",],)def test_breakdown_stats_are_opt_in_and_described(self, alias):