Hi, >From what I have seen, the new campaign_search_term_insight report doesn't work as intended. Basically, you cannot get search terms from this report: once you include *segments.search_term*, the report fails. I've tested this via API and Ads Scripts – no difference. Arthur's queries are basically the most reduced ones and should be ideal to confirm this.
Aside from that, there are some constraints to this report that are neither mentioned in its documentation <https://developers.google.com/google-ads/api/fields/v14/campaign_search_term_insight> nor caught by its query builder <https://developers.google.com/google-ads/api/fields/v14/campaign_search_term_insight_query_builder>. Instead, you have to learn about them through error messages. So far: 1. 'segments.search_term' can only be selected along with 'segments.search_subcategory' 2. campaign_search_term_insight can only be selected when filtering by a single 'campaign_search_term_insight.campaign_id' in WHERE clause 3. "segments.search_subcategory","segments.search_term" can only be selected when filtering by a single 'campaign_search_term_insight.id' in WHERE clause 2 and 3 mean that you need to use both campaign_search_term_insight.id and campaign_search_term_insight.campaign_id to get search terms. First off, it seems redundant to require the campaign_id when there's already the insight's id. The restriction to one insight per query makes the report hard to use. Let's say you want to get all search terms for a campaign (provided the report would work as apparently intended). *In the UI:* Navigate to the report and click download. You'll get a complete report with columns for categories, subcategories, search terms, and all metrics. Easy. *Via API:* 1. Run the report with a simple query that only gets you *campaign_search_term_insight.id* 2. (Loop) For each *campaign_search_term_insight.id*: Run a report with *campaign_search_term_insight.id* in the WHERE clause For a PMax shopping campaign, this easily means thousands of queries. This can't be how we're supposed to use this report... *tl;dr* 1. Querying for search terms results in an error 2. The documentation is incomplete 3. The restriction of one insight per query complicates things unneccessarily. Thanks for reading, have a good week! Martin On Friday, 18 August 2023 at 18:51:58 UTC+2 Arthur wrote: > Hi everyone, > > If you don't mind me appending to this thread, I'd like to add a similar > case with null values and a false positive in the GAQL Query Validator > (v14). All based on the campaign_search_term_insight report. > > *1/3) Empty results - but correct number of items in result set* > I modified Alex's query. In particular the two segments > "search_subcategory" and "search_term" were added for more detail. Doing so > resulted in the API stating that a WHERE condition of the field " > campaign_search_term_insight.id" is required. Passing this as well, > returned the correct number of items successfully (here 14, just as I see > in the Google Ads Web UI). But all of them were empty. See query and result > here: > > QUERY: > """ > SELECT > campaign_search_term_insight.campaign_id, > campaign_search_term_insight.category_label, > campaign_search_term_insight.id, > segments.search_subcategory, > segments.search_term > FROM campaign_search_term_insight > WHERE > campaign_search_term_insight.campaign_id = 'xxx' > and campaign_search_term_insight.id = 'yyy' > """ > RESULT: > """ > {'results': [ > {'segments': {}}, > {'segments': {}}, > {'segments': {}}, > {'segments': {}}, > {'segments': {}}, > {'segments': {}}, > {'segments': {}}, > {'segments': {}}, > {'segments': {}}, > {'segments': {}}, > {'segments': {}}, > {'segments': {}}, > {'segments': {}}, > {'segments': {}}], > 'fieldMask': > 'campaignSearchTermInsight.campaignId,campaignSearchTermInsight.categoryLabel,campaignSearchTermInsight.id,segments.searchSubcategory,segments.searchTerm'} > """ > > *2/3) Internal Server Error* > And once I add a metric such as "metrics.impressions" to SELECT, an > internal error occurs. > QUERY: > """ > SELECT > campaign_search_term_insight.campaign_id, > campaign_search_term_insight.category_label, > campaign_search_term_insight.id, > segments.search_subcategory, > segments.search_term, > *metrics.impressions* > FROM campaign_search_term_insight > WHERE > campaign_search_term_insight.campaign_id = 'xxx' > and campaign_search_term_insight.id = 'yyy' > """ > ERROR: > """ > Request made: > ClientCustomerId: xxx, > Host: googleads.googleapis.com, > Method: /google.ads.googleads.v14.services.GoogleAdsService/Search, > RequestId: DpspNLx6Qb9V8b7DCVkeZQ, > IsFault: True, > FaultMessage: Internal error encountered. > """ > > *3/3) False positive in GAQL Query Validator* > To see the false positive in the GAQL Query Validator, please validate > this query (which is the above one, but without the WHERE conditions): > https://developers.google.com/google-ads/api/fields/v14/query_validator > """ > SELECT > campaign_search_term_insight.campaign_id, > campaign_search_term_insight.category_label, > campaign_search_term_insight.id, > segments.search_subcategory, > segments.search_term > FROM campaign_search_term_insight > """ > The validation shows a valid query. But as stated above, the API requires > the campaign_id and id to be filtered by, within WHERE. Hence, I expected > the validator to hint for these two missing conditions. > """ > WHERE > campaign_search_term_insight.campaign_id = 'xxx' > and campaign_search_term_insight.id = 'yyy' > """ > > *So my question is this: Is there anything I am missing in formulating the > GAQL query to retrieve actual data instead of the correct number of empty > items?* > > *fyi, the Python code for running the queries, if relevant:* > *"""* > *#versions:* > *#Python 3.11.2* > > > > > > *#google-ads 21.2.0#google-api-core > 2.11.0#google-auth 2.22.0#google-auth-oauthlib > 1.0.0#googleapis-common-protos 1.59.1* > > > > > > > > > > > > > > > > > > > *from google.ads.googleads.client import GoogleAdsClientfrom > google.protobuf.json_format import MessageToDictclient = > GoogleAdsClient.load_from_storage(xxx, version="v14")service = > client.get_service("GoogleAdsService")query = """xxx"""search_request = > client.get_type("SearchGoogleAdsRequest")search_request.customer_id = > xxxsearch_request.query = querysearch_request.page_size = 1000results = > service.search(request=search_request)MessageToDict(results._pb)* > *"""* > > Thank you and kind regards, > Arthur > > Google Ads API Forum Advisor schrieb am Donnerstag, 17. August 2023 um > 15:05:49 UTC+2: > >> Hi Alex, >> >> Thank you for reaching out to Google Ads API Forum. >> >> Kindly note that we could only provide support to Google Ads API-related >> concerns and technical implementations. With this, you may note that the >> API only reflects the UI which means that if there is available data in the >> UI then the API should be able to manage or pull the same. With regards to >> your concern, could you share with us the full UI screenshot (without >> cropping) showing the data you are trying to retrieve using the said query? >> This is so we could further check on our end and provide more appropriate >> guidance. >> >> You may then send the requested information privately via the Reply to >> author option. If this option is not available, you may send the details >> directly to our *googleadsa...@google.com* alias instead. >> This message is in relation to case "ref:_00D1U1174p._5004Q2ntKRb:ref" >> >> Thanks, >> >> [image: Google Logo] Google Ads API Team >> >> >> -- -- =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ Also find us on our blog: https://googleadsdeveloper.blogspot.com/ =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ You received this message because you are subscribed to the Google Groups "AdWords API and Google Ads API Forum" group. To post to this group, send email to adwords-api@googlegroups.com To unsubscribe from this group, send email to adwords-api+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/adwords-api?hl=en --- You received this message because you are subscribed to the Google Groups "Google Ads API and AdWords API Forum" group. To unsubscribe from this group and stop receiving emails from it, send an email to adwords-api+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-api/f56b72b0-3965-41b6-87f3-2a883f6be85en%40googlegroups.com.