Posts tagged with google-ads-api

According to the documentation To generate historical metrics: Create a KeywordPlan, KeywordPlanCampaigns, KeywordPlanAdGroups, KeywordPlanCampaignKeywords, and KeywordPlanAdGroupKeywords. Call KeywordPlanService.GenerateHistoricalMetrics with that keyword plan.

These plans come out as a 4-element, slash-delimited string, e.g. customers/1879809528/keywordPlanCampaigns/413340892. However, after modifying the sample code to call GenerateHistoricalMetrics I find that the API at that point expects a long, the KeywordPlanId.

Is this number the 4th item in the plan string? Apparently not, as this slice out of the trace logs indicates:

... Response -------- Headers: {   "content-disposition": "attachment",   "request-id": "ahE6lqAnzToj3H65rHtHbA",   "date": "Mon, 30 May 2022 06:39:19 GMT",   "alt-svc": "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000,h3-Q050=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000,quic=\":443\"; ma=2592000; v=\"46,43\"" } { "results": [ { "resourceName": "customers/1879809528/keywordPlanCampaigns/413340892" } ] } ... Response -------- ... Fault: {   "StatusCode": 3,   "Details": "Request contains an invalid argument.",   "RequestId": "mMZTztmu4ufHpgJ77xph9Q",   "Failure": {     "errors": [       {         "errorCode": {           "keywordPlanError": "KEYWORD_PLAN_NOT_FOUND"         },         "message": "No plan with planId[413340892] exists"       }     ],     "requestId": "mMZTztmu4ufHpgJ77xph9Q"   } } 

So how does one get from plan to metrics?

I am trying to find the total cost of google ads campaigns that are created via a particular manager account or via google ads api.

I tried the change event query where it gives me all the campaigns created via google ads but the issue is with change_event.change_date_time. It requires this filter otherwise it throws an error. Because of this filter, I am only getting campaigns that are created in this specific time period, but I need all campaigns.

SELECT   change_event.campaign FROM change_event WHERE   campaign.status != 'REMOVED'   AND change_event.change_date_time >= '${from_date}'   AND change_event.change_date_time <= '${to_date}'   AND change_event.client_type = 'GOOGLE_ADS_API' ORDER BY change_event.change_date_time ASC LIMIT 10000 

Reference Link: https://developers.google.com/google-ads/api/fields/v9/change_event_query_builder

I have many campaigns and I want to summarize the spends by all the states (USA states) and based on from and to dates.

I went through the https://developers.google.com/google-ads/api/docs/reporting/overview but I dont see any point that can determine the spends based on states.

Which endpoint I need to use in Google Ads API: In the FB I am using https://graph.facebook.com/v13.0/act_2264578877108750/insights?access_token=<ACCESS_TOKEN>&fields=spend&breakdowns=region%2Ccountry&level=ad&time_range=%7B%27since%27%3A%272022-05-15%27%2C%27until%27%3A%272022-05-15%27%7D&limit=100&after=OTkZD

Any help is really appreciated.

Suppose if the value of Line item (Cost per Unit) is $45.45 in the report that we get from Google Ad Manager 360 UI , the same report when extracted through a java application using ad manager API gives value '45454000' . Why is this conversion done ? is it specific to any API version? I'm using v202111 in my application.