googleads / google-ads-php

Google Ads API Client Library for PHP
https://developers.google.com/google-ads/api/docs/client-libs/php
Apache License 2.0
291 stars 260 forks source link

advertisingChannelType = 12 #795

Closed macrognathus closed 2 years ago

macrognathus commented 2 years ago

We get advertisingChannelType = 12 instead of advertisingChannelType = DISCOVERY.

Method Name: /google.ads.googleads.v10.services.GoogleAdsService/SearchStream Host: googleads.googleapis.com Headers: { "x-goog-api-client": "gl-php\/8.0.12 gccl\/14.0.0 gapic\/14.0.0 gax\/1.12.0 grpc\/1.42.0 rest\/1.12.0", "x-goog-request-params": "customer_id=hidden", "developer-token": "REDACTED", "login-customer-id": "hidden" } Request: {"customerId":"hidden","query":"SELECT customer.id, customer.descriptive_name, customer.currency_code, customer.time_zone, campaign.id, campaign.name, campaign.status, campaign.serving_status, campaign.start_date, campaign.end_date, campaign.advertising_channel_sub_type, campaign.advertising_channel_type, bidding_strategy.name, campaign.bidding_strategy, campaign.bidding_strategy_type, campaign.campaign_budget, campaign_budget.explicitly_shared, campaign_budget.period, campaign_budget.amount_micros, campaign.percent_cpc.enhanced_cpc_enabled, campaign.manual_cpc.enhanced_cpc_enabled, campaign.tracking_url_template, segments.ad_network_type, segments.date, metrics.impressions, metrics.clicks, metrics.cost_micros, metrics.conversions, metrics.conversions_value, metrics.view_through_conversions, metrics.all_conversions, metrics.all_conversions_value, metrics.cross_device_conversions, metrics.engagements, metrics.interactions, metrics.video_quartile_p100_rate, metrics.video_quartile_p25_rate, metrics.video_quartile_p50_rate, metrics.video_quartile_p75_rate, metrics.video_views, metrics.gmail_forwards, metrics.gmail_saves, metrics.gmail_secondary_clicks, metrics.active_view_impressions, metrics.active_view_measurable_impressions, metrics.active_view_measurable_cost_micros, metrics.invalid_clicks, metrics.average_page_views, metrics.average_time_on_site, metrics.percent_new_visitors, metrics.search_exact_match_impression_share, metrics.search_impression_share, metrics.absolute_top_impression_percentage, metrics.top_impression_percentage, metrics.search_absolute_top_impression_share, metrics.search_top_impression_share, metrics.content_impression_share, metrics.content_budget_lost_impression_share, metrics.content_rank_lost_impression_share, metrics.search_budget_lost_impression_share, metrics.search_rank_lost_impression_share, metrics.bounce_rate, metrics.phone_impressions, metrics.phone_calls FROM campaign WHERE segments.date>='2022-01-31' AND segments.date<='2022-03-31' ORDER BY segments.date DESC "}

Response

... "customer":{"resourceName":"customers/hidden","id":"hidden","descriptiveName":"Hidden","currencyCode":"USD","timeZone":"America/New_York"},"metrics":{"activeViewImpressions":"0","activeViewMeasurableCostMicros":"0","activeViewMeasurableImpressions":"0","allConversionsValue":0,"allConversions":0,"averagePageViews":1,"averageTimeOnSite":0,"bounceRate":1,"clicks":"7","conversionsValue":0,"conversions":0,"costMicros":"6600000","engagements":"0","gmailForwards":"0","gmailSaves":"0","gmailSecondaryClicks":"0","impressions":"141","interactions":"7","invalidClicks":"0","percentNewVisitors":0.5714285714285714,"phoneCalls":"0","phoneImpressions":"0","videoViews":"0","viewThroughConversions":"0"},"segments":{"adNetworkType":"SEARCH_PARTNERS","date":"2022-03-30"}},{"campaignBudget":{"resourceName":"customers/2757228782/campaignBudgets/10530109811","amountMicros":"75000000","explicitlyShared":false,"period":"DAILY"},"campaign":{"resourceName":"customers/2757228782/campaigns/16509533404","id":"16509533404","name":"Attack - Custom Segment | Discovery","status":"ENABLED","servingStatus":"SERVING","advertisingChannelType":12,"campaignBudget":"customers/2757228782/campaignBudgets/10530109811","biddingStrategyType":"MAXIMIZE_CONVERSIONS","startDate":"2022-03-08","endDate":"2037-12-30"} ...

"requestId":"Q0oC3CKpIHzrVcwdff_WWw"}

We also get "advertisingChannelType":"SEARCH" in the same response which is expected behavior.

We are interested in kind of map berween constants and names for advertisingChannelType, like 12 => 'DISCOVERY' . Or ideally in fix of this issue and have advertisingChannelType as value from documentation enum https://developers.google.com/google-ads/api/fields/v10/campaign#campaign.advertising_channel_type

Also reached Google Ads API support on this, here is their answer: "I pulled a REST Interface version of your report and the 12's didn't show up. You may reach out to the issue tracker as this seems to be a Client Library specific issue."

Thanks in advance!

PierrickVoulet commented 2 years ago

Hi @macrognathus,

All enums have a util method that can be used to dynamically retrieve the names associated to ID values (example with AdGroupAdStatus). The same type of method exists for AdvertisingChannelType. Also, you can find the associations of IDs and names by checking the constants.

When it comes to the reason why you see an integer value in the response instead of string. This is because the support of Discovery campaigns was added to Google Ads API starting with the version V10.1 and we added the support of the version V10.1 of Google Ads API starting with the version 15.0.0 of this library. You are using the version 14.0.0 of this library, could you please upgrade to 15.0.0 and let us know if that helps?

macrognathus commented 2 years ago

Pierrick Voulet, thanks so much for your quick and complete answer! I can confirm that upgrade to 15.0.0 resolved my issue with Discovery Channel :) Thank you!