How to Set Audience Targeting (Interest, Age, Gender) in Demand Gen Campaigns via API with audience_grouped

44 views
Skip to first unread message

Ashish Chaturvedi (Ashu)

unread,
Apr 30, 2025, 3:58:07 AMApr 30
to Google Ads API and AdWords API Forum

Dear Google Ads API Support,

We’re currently working to automate Demand Gen campaign setup using the Google Ads API (v19, PHP client). Our goal is to programmatically apply audience targeting—including interest segments, age ranges, and genders—at the ad group level.

We attempted the following setup to include user interest segments:

```
$audienceIds = [91906, 91904, 91907, 91908]; // Example user interest IDs

foreach ($audienceIds as $audienceId) {
    $adGroupCriterion = new AdGroupCriterion([
        'ad_group' => $adGroupResourceName,
        'user_interest' => new UserInterestInfo([
            'user_interest_category' => ResourceNames::forUserInterest($customerId, $audienceId)
        ]),
        'status' => AdGroupCriterionStatus::ENABLED,
    ]);

    $adGroupCriterionOperation = new AdGroupCriterionOperation();
    $adGroupCriterionOperation->setCreate($adGroupCriterion);
    $adGroupCriterionOperations[] = $adGroupCriterionOperation;
}
```


However, the request failed with this error:

```
CANNOT_ADD_AUDIENCE_SEGMENT_CRITERION_WHEN_AUDIENCE_GROUPED_IS_SET Audience segment attachment is not allowed when use audience grouped bit is set to true.
```

This indicates that Demand Gen ad groups use audience_grouped targeting and do not accept individual user_interest criteria directly.

We would appreciate your help answering the following:


✅ What We Need to Know:
  1. What is the correct and supported way to apply the following via the API for Demand Gen ad groups when audience_grouped is enabled?

    • Interest segments

    • Age group targeting

    • Gender targeting

  2. Is there a recommended structure (e.g., ad_group.audience or similar grouped targeting object) that should be used instead of AdGroupCriterion?

  3. Can you provide a working example or reference documentation for applying these audience attributes under audience_grouped logic?

  4. Is it possible to modify these fields post-ad group creation, or must it be done at the time of ad group setup?



Thank you in advance for your assistance.

Best regards,

Google Ads API Forum Advisor

unread,
Apr 30, 2025, 9:37:19 AMApr 30
to ashish007...@gmail.com, adwor...@googlegroups.com
Hi,

Thank you for contacting the Google Ads API support team.

By reviewing your concern, I understand you are encountering the criterion error CANNOT_ADD_AUDIENCE_SEGMENT_CRITERION_WHEN_AUDIENCE_GROUPED_IS_SET which specifies the audience segment criteria cannot be added when use_audience_grouped bit is set. In order to investigate your issue, kindly provide us with the complete API logs (request and response logs with request-id and request header) generated at your end so that we can investigate this issue 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 guide PHP to enable logging at your end. For REST interface requests, you can enable logging via the curl command by using the -i flag.

Additionally, I would recommend you to check this target setting of audience documentation for more information. 

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-04-30 13:36:35Z GMT] This message is in relation to case "ref:!00D1U01174p.!500Ht01qVOx6:ref" (ADR-00302998)



Reply all
Reply to author
Forward
0 new messages