Posts under category google-ads-api

I am using Google Ads PHP library to create Campaign.

I created almost any type of campaigns but didn't manage to optimize them by specific Conversion Actions.

For example:

I have created 3 different Conversion Actions:

customers/[CUSTOMER_ID]/conversionActions/[CONVERSION_ACTION_ID_0] customers/[CUSTOMER_ID]/conversionActions/[CONVERSION_ACTION_ID_1] customers/[CUSTOMER_ID]/conversionActions/[CONVERSION_ACTION_ID_2]

Then I created a Campaign:

customers/[CUSTOMER_ID]/campaigns/[CAMPAIGN_ID]

I set bidding strategy to MAXIMIZE_CONVERSIONS and then tried to set Conversion Actions to optimize to. This is my code snippet:

$campaign->setMaximizeConversions(   new CommonMaximizeConversions([     'target_cpa' => $this->convert()->micros(1)   ]) ); $campaign->setSelectiveOptimization(   new SelectiveOptimization([     'conversion_actions' => [       'customers/[CUSTOMER_ID]/conversionActions/[CONVERSION_ACTION_ID_0]',       'customers/[CUSTOMER_ID]/conversionActions/[CONVERSION_ACTION_ID_1]'     ]   ]) ); 

It gives me this error:

{     "message": {         "message": "Request contains an invalid argument.",         "code": 3,         "status": "INVALID_ARGUMENT",         "details": [             {                 "@type": "type.googleapis.com/google.ads.googleads.v10.errors.GoogleAdsFailure",                 "errors": [                     {                         "errorCode": {                             "requestError": "UNKNOWN"                         },                         "message": "The error code is not in this version.",                         "trigger": {                             "stringValue": ""                         },                         "location": {                             "fieldPathElements": [                                 {                                     "fieldName": "operations",                                     "index": 0                                 },                                 {                                     "fieldName": "create"                                 },                                 {                                     "fieldName": "selective_optimization"                                 },                                 {                                     "fieldName": "conversion_actions"                                 }                             ]                         }                     }                 ],                 "requestId": "xbgMUFFeP4447GFW_nJrIA"             }         ]     }, } 

Can you tell me what I am doing wrong? Or suggest any help?.

Thanks.

I am using google ads java sdk to get a list of accessible customer accounts as shown below:

ListAccessibleCustomersResponse response = customerService                     .listAccessibleCustomers(ListAccessibleCustomersRequest.newBuilder().build()); 

I am wondering if I can I can filter in order to only get enabled accounts.

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"                 }             }, 

let startDate = '2020-01-01'; let endDate = new Date().toISOString().slice(0, 10).toString(); // "WHERE segments.date BETWEEN '2020-01-01' AND 'endDate' " 

Returns this error:

Exception: Call to GoogleAdsService.Search failed: Condition 'segments.date BETWEEN '2020-01-01' and 'endDate'' is invalid: BETWEEN operator must have exactly two values that are both numbers or both date strings in 'YYYY-MM-DD' format.

How can I set endDate to YESTERDAY?