Demand Gen Campaign Creation with "Clicks" Goal in PHP - Getting API Error

51 views
Skip to first unread message

Ashish Chaturvedi (Ashu)

unread,
Aug 18, 2025, 12:41:14 PMAug 18
to Google Ads API and AdWords API Forum

Hello Google Ads Community,

I am trying to create a Demand Gen campaign using the PHP client library (version 19). My goal is to set the campaign objective to "Clicks" as it appears in the Google Ads UI.

Screenshot 2025-08-18 at 9.51.12 PM.png
However, I'm facing an API error that I can't resolve. I initially tried using maximize_clicks, but that resulted in a No such field maximize_clicks error, even with the latest library. After trying a different approach, the issue persists.

Here is my code snippet for creating the campaign. I've noted that I am currently using maximize_conversions as a test, but my true goal is "Clicks".

try {
    // Creates a single shared budget to be used by the campaigns added below.
    $budgetResourceName = $this->addCampaignBudget($customerId, $params);
    $budgetResourceName = json_decode($budgetResourceName->getContent(),true);

    // Build network settings
    $networkSettings = new NetworkSettings([
        'target_google_search' => true,
        'target_search_network' => true,
        'target_content_network' => true,
        'target_partner_search_network' => false
    ]);
    $name = $params['name'];

    // Prepare your campaign parameters
    $campaignData = [
        'name' => $name,
        'advertising_channel_type' => AdvertisingChannelType::DEMAND_GEN,
        'campaign_budget' => $budgetResourceName['response'],
        'network_settings' => $networkSettings,
        'maximize_conversions' => new MaximizeConversions(), // This is a placeholder; I need 'Clicks'
        'status' => CampaignStatus::PAUSED
    ];

    if (!empty($params['start_date'])) {
        $campaignData['start_date'] = $params['start_date'];
    }

    if (!empty($params['end_date'])) {
        $campaignData['end_date'] = $params['end_date'];
    }

    $campaign = new Campaign($campaignData);

    // ... (rest of the code to mutate the campaign)

} catch (GoogleAdsException $ex) {
    // ... (error handling)
}

My core issue is: What is the correct way to set the bidding strategy for a "Clicks" goal on a Demand Gen campaign using the PHP client library?

Any guidance or a working code example would be greatly appreciated.

Thank you!

Google Ads API Forum Advisor

unread,
Aug 18, 2025, 5:52:07 PMAug 18
to ashish007...@gmail.com, adwor...@googlegroups.com
Hi,

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

From the provided image, the clicks uses the cpc bid strategy. I would recommend that you set the bidstrategy to manual_cpc. Kindly refer to this code example. Also, to assist your further with the code, could you please provide us with the complete API logs (request and response logs with request-id and request header) generated at your end. This would help us understand the issue and assist you accordingly.

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.NetPHPPythonRuby 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.

Thanks,
 
Google Logo Google Ads API Team

Feedback
How was our support today?

rating1    rating2    rating3    rating4    rating5
[2025-08-18 21:51:14Z GMT] This message is in relation to case "ref:!00D1U01174p.!500Ht01szPi2:ref" (ADR-00330269)



Google Ads API Forum Advisor

unread,
Aug 18, 2025, 5:53:22 PMAug 18
to ashish007...@gmail.com, adwor...@googlegroups.com
Hi,

Kindly disregard my previous email. Thank you for reaching out to the Google Ads API support team.


From the provided image, the clicks uses the cpc bid strategy. I would recommend that you set the bidstrategy to manual_cpc. Kindly refer to this code example. Also, to assist your further with the code, could you please provide us with the complete API logs (request and response logs with request-id and request header) generated at your end. This would help us understand the issue and assist you accordingly.

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.NetPHPPythonRuby 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.

Thanks,
 
Google Logo Google Ads API Team

Feedback
How was our support today?

rating1    rating2    rating3    rating4    rating5

[2025-08-18 21:52:40Z GMT] This message is in relation to case "ref:!00D1U01174p.!500Ht01szPi2:ref" (ADR-00330269)



Message has been deleted
Message has been deleted

Google Ads API Forum Advisor

unread,
6:06 AM (8 hours ago) 6:06 AM
to flywheel....@gmail.com, adwor...@googlegroups.com
Hi,

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

Based on the logs, I could see that you have encountered OPERATION_NOT_PERMITTED_FOR_CONTEXT error particularly at the 'manual_cpc' field while creating the demand gen campaign. Kindly note that 'manual_cpc' bidding strategy is not supported for the demand gen campaigns and that's the main reason why you are encountering OPERATION_NOT_PERMITTED_FOR_CONTEXT error. Supported bidding strategies for the demand gen campaigns are maximize clicks, target CPA, maximize conversions, and target ROAS. I would recommend you to refer to this documentation for more detailed information regarding the demand gen campaign bidding strategies. 

Additionally, as your main goal is to create the demand gen campaign with 'Clicks' as the main goal, so I would recommend you to create the demand gen campaign with 'maximize clicks' as a bidding strategy. Maximize clicks corresponding bidding strategy name in the Google Ads API is 'TARGET_SPEND'. I would recommend you to refer to this guide for more information. We have tried this approach and we were able to achieve it as per your requirement, so I would suggest you to remove the 'manaul_cpc' and try adding the TARGET_SPEND and let us know how it goes from your end. However, I am sharing a sample request body for the campaign operation:
{
  "operations": [
    {
      "create": {
        "advertisingChannelType": "DEMAND_GEN",
        "name": "Demand gen campaign cpc",
        "campaignBudget": "customers/{customerId}/campaignBudgets/{campaignBudgetId}",
        "status": "ENABLED",
        "containsEuPoliticalAdvertising": "DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING",
        "targetSpend": {}
      }
    }
  ]
}
As you are performing bulk mutate calls using the GoogleAdsService and the campaign operation failed which resulted in the following operations to fail and resulted in a RESOURCE_NOT_FOUND error. Once you update your campaign operation with the 'TARGET_SPEND' bidding strategy the corresponding operations will succeed and the RESOURCE_NOT_FOUND error will get resolved. 
 

Thanks,
 
Google Logo Google Ads API Team

Feedback
How was our support today?

rating1    rating2    rating3    rating4    rating5

[2025-10-15 10:05:52Z GMT] This message is in relation to case "ref:!00D1U01174p.!500Ht01szPi2:ref" (ADR-00330269)



Reply all
Reply to author
Forward
0 new messages