Campaign search term insights call fails

667 views
Skip to first unread message

Ionut Voda

unread,
Oct 31, 2023, 5:29:46 PM10/31/23
to Google Ads API and AdWords API Forum
Hello there,

Whenever I try to get segments.search_term out of the campaign_search_term_insight report, the Ads service fails. 

This is the request error:

Request made: ClientCustomerId: 6809911040, Host: googleads.googleapis.com, Method: /google.ads.googleads.v15.services.GoogleAdsService/SearchStream, RequestId: 7TdmMt8vVAuXNkL0ndPelA, IsFault: True, FaultMessage: Internal error encountered.
500 Internal error encountered. [type_url: "type.googleapis.com/google.ads.googleads.v15.errors.GoogleAdsFailure"
value: "\n%\n\002P\002\022\037An internal error has occurred.\022\0267TdmMt8vVAuXNkL0ndPelA"
]

And this is the GAQL that I use:

SELECT metrics.impressions, metrics.ctr, metrics.conversions,
metrics.clicks, segments.search_subcategory, segments.search_term
FROM campaign_search_term_insight
WHERE campaign_search_term_insight.campaign_id = '16581967632'
AND campaign_search_term_insight.id = '4144139027821159424'
AND segments.date BETWEEN '2023-09-01' AND '2023-09-30'

Is there any way to retrieve the search terms for a given campaign and insight id pair ?

Thanks! Ionut

Google Ads API Forum Advisor

unread,
Oct 31, 2023, 10:03:57 PM10/31/23
to ionut...@gmail.com, adwor...@googlegroups.com
Hi,

Thank you for reaching out to the Google Ads API support team.

By reviewing your concern, I understand that you are getting 'INTERNAL_ERROR' with status code 500 while updating the SKAN schema using the Google Ads API. Kindly note that the INTERNAL_ERROR occurs when something unexpected happened while processing the request. The common cause could be the API isn't functioning correctly. However, this is transient in nature and the API request will work again when retrying it after 30 seconds or some time. I have tried to replicate the issue but I got a successful response upon making the API call. You may also retry any requests that failed with this error, using an exponential backoff schedule for the retries. Here is a code example demonstrating how to implement an exponential back off strategy.

Hope this helps. If you have any more queries, please feel free to get back to us.
 
This message is in relation to case "ref:!00D1U01174p.!5004Q02q9T1G:ref"

Thanks,
 
Google Logo Google Ads API Team


Google Ads API Forum Advisor

unread,
Oct 31, 2023, 10:07:26 PM10/31/23
to ionut...@gmail.com, adwor...@googlegroups.com
Hi,

Thank you for reaching out to the Google Ads API support team.

Please disregard my previous email. By reviewing your concern, I understand that you are getting 'INTERNAL_ERROR' with status code 500 while fetching the campaign_search_term_insight via Google Ads API. Kindly note that the INTERNAL_ERROR occurs when something unexpected happened while processing the request. The common cause could be the API isn't functioning correctly. However, this is transient in nature and the API request will work again when retrying it after 30 seconds or some time. I have tried to replicate the issue but I got a successful response upon making the API call. You may also retry any requests that failed with this error, using an exponential backoff schedule for the retries. Here is a code example demonstrating how to implement an exponential back off strategy.

Ionut Voda

unread,
Nov 1, 2023, 6:05:07 AM11/1/23
to Google Ads API and AdWords API Forum
Hello,

I do have a retry mechanism in place. That is not the problem. The problem is that I have been trying to run that query for the last 3 days, multiple times a day, and every time I run into the 500 error. I also tried 3 minutes before writing this to you. Doesn't seem to be transient, but rather a consistent error. Otherwise I wouldn't have reached you.

Thanks,
Ionut

Google Ads API Forum Advisor

unread,
Nov 1, 2023, 10:23:00 AM11/1/23
to ionut...@gmail.com, adwor...@googlegroups.com
Hi,

Thank you for getting back to us.

Kindly allow me to raise this request with rest of our team and one of our colleagues will reach out to you once we have an update on this.

Google Ads API Forum Advisor

unread,
Nov 2, 2023, 4:53:00 PM11/2/23
to ionut...@gmail.com, adwor...@googlegroups.com
Hi,

Thank you for getting back to us.

In order to investigate your issue, kindly provide us with the customer-id and updated complete API logs (request and response with request-id and request header) generated at your end to assist you better.

If you are using a client library and haven't enabled the logging yet, I would request you to enable logging for the specific client library that you are using. You can refer to the guides Java, .Net, PHP, Python, Ruby or Perl to enable logging at your end. For REST interface requests, you can enable logging via the curl command by using the -i flag.

You can send the details via Reply privately to the author option, or direct private reply to this email.
Message has been deleted

Google Ads API Forum Advisor

unread,
Nov 3, 2023, 8:41:53 AM11/3/23
to ionut...@gmail.com, adwor...@googlegroups.com
Hi Ionut,

Thank you for providing the additional information.

Please be informed that I have removed your response from the forums as it contains the PII information.

I will check with our team regarding your issue and one of my team members will reach out to you once we have an update on this. Meanwhile, your patience is highly appreciated.

Moshe Shechter

unread,
Nov 5, 2023, 10:30:32 AM11/5/23
to Google Ads API and AdWords API Forum
Hello,

I've been having the same exact issue on my side. An API call allows for the fetching of all category label data for a single campaign, but once data is segmented  by search_subcategory and search_term (with a filter for a specific campaign id and campaign_search_term_insight id) the response is always a 500 Internal error. I am using V15 of the API, and as an example, request ID RBNEKmBIDyFSwffWvAYTxg returns this the following error:

grpc._channel._SingleThreadedRendezvous: <_SingleThreadedRendezvous of RPC that terminated with:
        status = StatusCode.INTERNAL
        details = "Internal error encountered."
        debug_error_string = "{"created":"@1699180007.163000000","description":"Error received from peer ipv4:142.250.179.138:443","file":"src/core/lib/surface/call.cc","file_line":1075,"grpc_message":"Internal error encountered.","grpc_status":13}"


google.api_core.exceptions.InternalServerError: 500 Internal error encountered. [type_url: "type.googleapis.com/google.ads.googleads.v15.errors.GoogleAdsFailure"
value: "\n%\n\002P\002\022\037An internal error has occurred.\022\026RBNEKmBIDyFSwffWvAYTxg"

Thanks,

Moshik

Google Ads API Forum Advisor

unread,
Nov 6, 2023, 1:05:40 PM11/6/23
to mo...@abagada.com, adwor...@googlegroups.com
I see you are using a Python library and I will assume that it is ours that is found at https://github.com/googleads/google-ads-python.

Please send me:
 
  • The version of python you are using. `python -V' at the command line.
  • The version of our client library you are using.
  • Your list of dependencies for the library `python -m pip list`
We have tried this query internally using Curl and and your credentials and we receive the expected response. The error you are receiving points to a grpc error. I want to determine if it is a issue with the Python environment which is why I need the above details.

 
This message is in relation to case "ref:!00D1U01174p.!5004Q02q9T1G:ref"

Thanks,
 
Google Logo
Bob Hancock
Google Ads API Team


Moshe Shechter

unread,
Nov 7, 2023, 7:21:16 AM11/7/23
to Google Ads API and AdWords API Forum
Hello,

I am using the python library. As for versions:
  • Python 3.9.5
  • google-ads library v 22.1.0
  • See attached output from pip freeze
Please note that all other requests to the API work perfectly well. For completeness, please see GAQL query (campaign and id are specific IDs replaced in the sent query):

    SELECT
        campaign_search_term_insight.category_label,
        segments.date,
        segments.search_subcategory,
        segments.search_term,
        metrics.clicks,
        metrics.impressions,
        metrics.conversions,
        metrics.conversions_value
    FROM
        campaign_search_term_insight
    WHERE
        segments.date DURING LAST_7_DAYS
        AND campaign_search_term_insight.campaign_id ='{campaign}'
        AND campaign_search_term_insight.id ='{id}'

Thanks,

Moshik

packages.txt

Google Ads API Forum Advisor

unread,
Nov 7, 2023, 1:48:40 PM11/7/23
to mo...@abagada.com, adwor...@googlegroups.com
Thanks for the data.

I saw that in your first interaction, provided the campaign id. If this is the one the consistently returns the error, please confirm.

The error indicates that grpc has encountered an error and provided the stacktrace that is in the logs. This only indicates that an invariant has changed which doesn't point us to the core of the problem. 

When we run the query internally with your credentials, it succeeds. This is evidence that it is likely not a data problem. 

Since the error occurs in grpc, the RPC framwork, it indicates a problem of communication between your side and our sever. The next debugging steps are:
  • Determine if the error only occurs for this query with specific values or if this query fails with all values. Values here indicates campaign and insight.
  • Attempt a failing query using Curl with the the command line option -i. This will bypass the grpc client layer.
  • Upgrade to the latest versions of grpcio and grpcio-status.
You can upgrade the versions of the two grpc packages with: python -m pip install --upgrade grpcio==1.56.2 grpcio-status==1.56.2

Let me know the outcome of the tests.

Moshe Shechter

unread,
Nov 7, 2023, 2:25:40 PM11/7/23
to Google Ads API and AdWords API Forum
Thank you for the response.

Several things:
1. The error only occurs for this particular query. All other queries work fine. The overall process run reporting tasks on a regular basis with no issues. The code itself runs perfectly when a different query is provided, even for the same resource, without the desired segements.
2. I've attempted this request via curl locally, and I am still receiving an internal error:

[{
  "error": {
    "code": 500,
    "message": "Internal error encountered.",
    "status": "INTERNAL",
    "details": [
      {
        "@type": "type.googleapis.com/google.ads.googleads.v15.errors.GoogleAdsFailure",
        "errors": [
          {
            "errorCode": {
              "internalError": "INTERNAL_ERROR"
            },
            "message": "An internal error has occurred."
          }
        ],
        "requestId": "CTtg8hIqUYtP4OIGZc5DPA"
      }
    ]
  }
}

I've added a redacted screenshot of the output for reference.  AS you can see - the same code runs well for a different query (stored in a query.json file), but fails to run when the query is modified. 

3. Updating the module as suggested produces the same error.

Thoughts?

error 500.png

Google Ads API Forum Advisor

unread,
Nov 7, 2023, 2:39:36 PM11/7/23
to mo...@abagada.com, adwor...@googlegroups.com
>>The error only occurs for this particular query. 

I'm still not clear what you mean. Do you mean with the values specified and that if you change 

When you say a different query, what does that mean? You just change the campaign id?

Since the Curl query returns an internal error it points to a back end problem that was being propagated to grpc.

I'll need to open an consultation with our back end team. For that, I'll need the request and response without any redactions. As soon as I have that I will open the consultation.

Moshe Shechter

unread,
Nov 7, 2023, 3:32:08 PM11/7/23
to Google Ads API and AdWords API Forum
Please let me know what you find, but to clarify, the code works for the following GAQL query (All results are returned, and match the results in the UI):

   SELECT
        campaign_search_term_insight.category_label,

        metrics.clicks,
        metrics.impressions,
        metrics.conversions,
        metrics.conversions_value
    FROM
        campaign_search_term_insight
    WHERE
        segments.date DURING LAST_7_DAYS
        AND campaign_search_term_insight.campaign_id ='19548801299'
    ORDER BY
       metrics.impressions ASC

Similarly, the code works for the following query (change highlighted in yellow) - a single result from the previous query is returned:

    SELECT
        campaign_search_term_insight.category_label,

        metrics.clicks,
        metrics.impressions,
        metrics.conversions,
        metrics.conversions_value
    FROM
        campaign_search_term_insight
    WHERE
        segments.date DURING LAST_7_DAYS
        AND campaign_search_term_insight.campaign_id ='19548801299'
        AND campaign_search_term_insight.id ='1563229965490945024'


However, the internal error is generated when the query is modified into the following:

   SELECT
        campaign_search_term_insight.category_label,
        segments.date,
        segments.search_subcategory,
        segments.search_term,

        metrics.clicks,
        metrics.impressions,
        metrics.conversions,
        metrics.conversions_value
    FROM
        campaign_search_term_insight
    WHERE
        segments.date DURING LAST_7_DAYS
        AND campaign_search_term_insight.campaign_id ='19548801299'
        AND campaign_search_term_insight.id ='1563229965490945024'

There seems to be no issue with the logic of the query, or the code.

Thanks,

Moshik

Google Ads API Forum Advisor

unread,
Nov 7, 2023, 4:18:53 PM11/7/23
to mo...@abagada.com, adwor...@googlegroups.com
Hi Moshe:

That is just the data that I need. I've asked a colleague from the campaign management team to take a look and will report back here when I have a response.

Moshe Shechter

unread,
Nov 12, 2023, 8:44:02 AM11/12/23
to Google Ads API and AdWords API Forum
Any update on this?

Google Ads API Forum Advisor

unread,
Nov 13, 2023, 1:11:34 PM11/13/23
to mo...@abagada.com, adwor...@googlegroups.com
No response yet from my colleague on the campaign team. I'll post a response here as soon as I hear something.

Moshe Shechter

unread,
Nov 19, 2023, 10:33:32 AM11/19/23
to Google Ads API and AdWords API Forum
Hello,

Bumping this up - it has been almost two weeks.

Thanks,

Moshik

Moshe Shechter

unread,
Nov 27, 2023, 10:04:20 AM11/27/23
to Google Ads API and AdWords API Forum
Hello,

Is this thread still live? Is there any progress? It has been nearly three weeks.

Thanks,

Moshik

Google Ads API Forum Advisor

unread,
Nov 27, 2023, 6:48:22 PM11/27/23
to mo...@abagada.com, adwor...@googlegroups.com
Hi Moshik,

My name is Devin, and I am stepping in while my colleague Bob is out of office. Thank you for following up here. I have reached out to our engineering team again. Someone on our team will reach out as soon as we have an update.

All the best,
Devin

The Google Ads API Team

ref:!00D1U01174p.!5004Q02q9T1G:ref

Google Ads API Forum Advisor

unread,
Jan 18, 2024, 7:42:15 PM1/18/24
to mo...@abagada.com, adwor...@googlegroups.com
Hi Moshe, it appears the issue has been resolved.

Would you please retry the query and let me know if you still receive an error? If so, would you please reply back with the request and response logs, including the request-id?

All the best,
Devin

ref:!00D1U01174p.!5004Q02q9T1G:ref

Moshe Shechter

unread,
Feb 19, 2024, 7:43:12 AM2/19/24
to Google Ads API and AdWords API Forum
Hello,

This issue has not been resolved on my side, and I am still seeing the same error every time, regardless of modifications made to the query.

The latest attempt is as follows:

query = '''
    SELECT
        campaign_search_term_insight.campaign_id,
        campaign_search_term_insight.category_label,
        campaign_search_term_insight.id,
        campaign_search_term_insight.resource_name,
        segments.date,
        segments.search_subcategory,
        segments.search_term,
        metrics.clicks,
        metrics.conversions,
        metrics.impressions,
        metrics.conversions_value
    FROM
        campaign_search_term_insight
    WHERE
        segments.date BETWEEN '2024-01-04' AND '2024-01-04' AND
        campaign_search_term_insight.campaign_id = '20312273196' AND
        campaign_search_term_insight.id = '20312273196'
'''


Running this query (RequestId: yW9nGvW8jQAGMWVLBmiYjQ) I receive the same internal error:

google.api_core.exceptions.InternalServerError: 500 Internal error encountered. [type_url: "type.googleapis.com/google.ads.googleads.v15.errors.GoogleAdsFailure"
value: "\n%\n\002P\002\022\037An internal error has occurred.\022\026yW9nGvW8jQAGMWVLBmiYjQ"
]

I've also tried the previously provided query, resulting in the same issue.

Please advise.

Thanks,

Moshik

Google Ads API Forum Advisor

unread,
Feb 19, 2024, 12:53:43 PM2/19/24
to mo...@abagada.com, adwor...@googlegroups.com
Hi,

Thank you for getting back to us.

I will check with our team regarding your issue and one of my team members will reach out to you once we have an update on this. Meanwhile, your patience is highly appreciated.

You may refer to this page which provides status information on the services that are part of Google Ads. 

 
This message is in relation to case "ref:!00D1U01174p.!5004Q02q9T1G:ref"

Thanks,
 
Google Logo Google Ads API Team

 

Google Ads API Forum Advisor

unread,
Feb 20, 2024, 9:28:19 AM2/20/24
to mo...@abagada.com, adwor...@googlegroups.com
Hello Mosche,

Sorry for your inconvenience.
I'm Thanet working with Bob and Devin on this issue.
Our engineers just rolled out the change that would help fix your issue, bu it hasn't hit production yet.
Could you please wait and try again in around 5 days? 

Best,
 
This message is in relation to case "ref:!00D1U01174p.!5004Q02q9T1G:ref"

Thanks,
 
Google Logo
Thanet Knack Praneenararat
Google Ads API Team


Joe Hall

unread,
Aug 20, 2024, 8:51:18 AM8/20/24
to Google Ads API and AdWords API Forum
Any update on this thread with a successful query pull? I am running into the same issue.

Google Ads API Forum Advisor

unread,
Aug 20, 2024, 1:53:24 PM8/20/24
to j...@trafficbyintent.com, adwor...@googlegroups.com
Hi,

Kindly note that the fix was deployed several months ago. Could you confirm if you are getting INTERNAL_ERROR? If yes, I would request you to kindly provide us with the complete API logs (request and response logs with request-id and request header) generated at your end to better assist you further.


If you are using a client library and haven't enabled the logging yet, I would request you to enable logging for the specific client library that you are using. You can refer to the guides Java, .Net, PHP, Python, Ruby or Perl to enable logging at your end. For REST interface requests, you can enable logging via the curl command by using the -i flag.

You can send the details via Reply privately to the author option, or direct private reply to this email.
 
This message is in relation to case "ref:!00D1U01174p.!5004Q02q9T1G:ref" (ADR-00208415)

Thanks,
 
Google Logo Google Ads API Team


 

Reply all
Reply to author
Forward
0 new messages