Posts tagged with google-ads-script

I was asked to call Google-Ads API in order to create a report with these fields:

I went to ad_group_ad table.

I wanted to make sure I understand this table's meaning: Why isn't this just called Ad?

What is the difference between Ad_group_ad and Ad_group tables?

There were a few metrics which I couldn't find in ad_group_ad I couldn't filter the views which contain them (for example impression_share)

I know impression_share exists for keywords and campaign, so I found them in the relevant tables. So I understand they cannot be broken down at an ad level.

But I still couldn't find the other highlighted metrics even at a campaign level.

Here is my campaign query try:

SELECT    metrics.clicks,    metrics.impressions,    metrics.ctr,    metrics.cost_micros,    metrics.cost_per_conversion,    metrics.cost_per_all_conversions,    metrics.all_conversions_from_interactions_rate,    metrics.all_conversions_value,    campaign.name,    campaign.id,    segments.device,    segments.date,    campaign.advertising_channel_type,    segments.click_type,    campaign.geo_target_type_setting.positive_geo_target_type,    campaign.geo_target_type_setting.negative_geo_target_type  FROM campaign  WHERE    segments.date BETWEEN '2020-01-01' AND '2022-01-01'  ORDER BY    campaign.start_date DESC  LIMIT 100  

I got this Fatal Error/Uncaught Error while linking with the Google Ads API. I've used the Github code and downloaded library from composer

Fatal error: Uncaught Error: Class "Google\Ads\GoogleAds\Examples\Utils\ArgumentParser" not found in googleAdword\examples\BasicOperations\GetCampaigns.php:44 Stack trace: #0 googleAdword\examples\BasicOperations\GetCampaigns.php(120): Google\Ads\GoogleAds\Examples\BasicOperations\GetCampaigns::main() #1

Tried all these solutions:

  1. reinstalling the lib, and not through zip downloading at first, but through git clone, and then install through composer etc.
  2. In the sample code of GetAccountInformation, there is a CUSTOMER_ID field that is required before you execute the code.(Already set)

I want to get the report as shown here https://prnt.sc/oG7ms7tOdVfH

The input is Country = USA Date from and Date to

But this gives non US states and it doesnt summarize the resuly by state names (not the state IDs)

Can anyone help me to get the REST API?

  curl "https://googleads.googleapis.com/v10/customers/${CUSTOMER_ID}/googleAds:searchStream" \    --header "Content-Type: application/json" \ --header "developer-token: ${DEVELOPER_TOKEN}" \    --header "login-customer-id: ${MANAGER_CUSTOMER_ID}" \    --header "Authorization: Bearer ${OAUTH2_ACCESS_TOKEN}" \    --data '{ "query": "       SELECT         PERFORMANCE COST       FROM LOCATION       WHERE COUNTRY = 'USA' AND           segments.date BETWEEN 20220101 AND 20220430      " }' 

I am using ads API for getting the spends based on state names of USA.

The below query gives segments.geo_target_state will be returned as an ID instead of name How can I combine this query with

SELECT  geo_target_constant.name,  geo_target_constant.canonical_name  FROM geo_target_constant  WHERE geo_target_constant.id = <<OBTAINED ID FROM THE BELOW QUERY>> 
curl "https://googleads.googleapis.com/v10/customers/${CUSTOMER_ID}/googleAds:searchStream" \   --header "Content-Type: application/json" \   --header "developer-token: ${DEVELOPER_TOKEN}" \   --header "login-customer-id: ${MANAGER_CUSTOMER_ID}" \   --header "Authorization: Bearer ${OAUTH2_ACCESS_TOKEN}" \   --data '{     "query": "       SELECT         campaign.name,         segments.geo_target_state,         metrics.cost_micros       FROM geographic_view       WHERE         geographic_view.location_type = LOCATION_OF_PRESENCE         AND segments.date BETWEEN 20220101 AND 20220430     "   }' 

That is geoTargetConstants/21136 must be decoded to "name": "New Jersey",

 "results": [             {                 "campaign": {                     "resourceName": "customers/1234/campaigns/1234",                     "name": "Display - macines - Leads Display Campaign Test - AA"                 },                 "metrics": {                     "costMicros": "66664821"                 },                 "segments": {                     "geoTargetState": "**geoTargetConstants/21136**"                 },                 "geographicView": {                     "resourceName": "customers/6383148790/geographicViews/2840~LOCATION_OF_PRESENCE"                 }             }, 

I am looking for the equivalents of Adwords API in the new Google ads API in PHP.

For example, the equivalent of

use Google\AdsApi\AdWords\v201809\cm\AgeRange; 

is

use Google\Ads\GoogleAds\V10\Common\AgeRangeInfo; 

But I can't find the exact equivalents for those for example:

use Google\AdsApi\AdWords\v201809\cm\GeoTargetTypeSetting; use Google\AdsApi\AdWords\v201809\cm\GeoTargetTypeSettingNegativeGeoTargetType; use Google\AdsApi\AdWords\v201809\cm\GeoTargetTypeSettingPositiveGeoTargetType; 

Do you know any translators from google adwords to google ads?