Retrieving Draft/Experiment Ad Groups

339 views
Skip to first unread message

Will Schymik

unread,
Nov 24, 2021, 3:00:43 PM11/24/21
to AdWords API and Google Ads API Forum
Hello,

I am currently using the API to create and update Campaign Experiments. I would like to update draft content in the Ad Group and Ad, however am running into trouble programmatically retrieving the identifiers of the draft Ad Group to perform modifications. When I create a new draft Campaign I am able to see that a new Ad Group is created from looking in the console, however when I query the ad_group view I only see the original Ad Group and not the draft. The same issue happens when I create an experiment as the experiment's Ad Groups do not show up in the ad_group view either. I am performing the below query that includes no filters:

SELECT
ad_group.id,
ad_group.resource_name,
ad_group.name,
ad_group.status,
ad_group.tracking_url_template,
ad_group.final_url_suffix,
ad_group.type,
campaign.id
FROM ad_group

Is there another way that I am supposed to be able to programmatically retrieve the identifiers of child objects of a draft campaign?

Thanks,
Will

Google Ads API Forum Advisor

unread,
Nov 25, 2021, 3:32:25 AM11/25/21
to will.s...@apartmentadvisor.com, adwor...@googlegroups.com

Hi Will,

Thanks for reaching out to us.

Kindly note that you may need to differentiate an experiment campaign and a base campaign in your search query by selecting campaign.experiment_type, which will be BASE, DRAFT, or EXPERIMENT to differentiate the type of campaign. You may refer to this guide in order to retrieve the identifiers of child objects of a draft campaign for reporting on experiments.

Also, note that we are currently working on a replacement for the experiments feature, which will require you to update your code once it is ready. We estimate that the feature will be released around February of 2022. If you are considering migrating to or implementing experiments, keep in mind that there will be upcoming work in order to continue using the feature once the replacement is ready. There will be a window of approximately three months where both approaches are supported during which you can migrate. If you only use or plan to use drafts, your workflow will be unaffected.

Let us know if you have any further questions.

Regards,
Reminder: Share your feedback about the Google Ads (AdWords) API! Take the 2021 Google Ads API and AdWords API Annual Survey
 

Google Logo
Yasar
Google Ads API Team
 


ref:_00D1U1174p._5004Q2Rw2hc:ref

Will Schymik

unread,
Nov 30, 2021, 9:42:41 AM11/30/21
to AdWords API and Google Ads API Forum
If anyone runs into this you need to add the following to your query after the WHERE clause:

PARAMETERS include_drafts=true

Google Ads API Forum Advisor

unread,
Dec 1, 2021, 12:40:07 PM12/1/21
to will.s...@apartmentadvisor.com, adwor...@googlegroups.com
Hi Will,

Is there anything else you need support for in Ads API?


Reminder: Share your feedback about the Google Ads (AdWords) API! Take the 2021 Google Ads API and AdWords API Annual Survey
 
Regards,
Google Logo
Aryeh Baker
Google Ads API Team
 


ref:_00D1U1174p._5004Q2Rw2hc:ref

Will Schymik

unread,
Dec 1, 2021, 3:35:14 PM12/1/21
to AdWords API and Google Ads API Forum
Sure, the issue I am currently having trouble with is transitioning a campaign from a Portfolio Bidding Strategy to a Standard Bidding Strategy. I am performing an update on the campaign, setting the correct fields for the standard bidding strategy, and trying various methods of setting the bidding strategy to empty (null, empty string). The campaign always stays associated with the old portfolio strategy. 

Ultimately what I am asking is how do you disassociate a portfolio bidding strategy from a campaign without reassociating it with a new one?

Thanks,
Will

Will Schymik

unread,
Dec 1, 2021, 3:36:06 PM12/1/21
to AdWords API and Google Ads API Forum

Google Ads API Forum Advisor

unread,
Dec 2, 2021, 10:29:26 AM12/2/21
to will.s...@apartmentadvisor.com, adwor...@googlegroups.com
Hi Will,

I was able to change from portfolio bidding to standard bidding by just entering a standard bid and update mask of the standard bid to the new bid strategy. To address your use case, could you privately send us a request and response log of API communication that returns this error? 

The request and response appears similar to the JSON Mappings in our REST documentation. Our client libraries have loggers with logging instructions, to see these instructions you can click on the client library you use in the sidebar of our client library guide and click on "Logging". Setting the logger to 'DEBUG' will get the desired log.

Will Schymik

unread,
Dec 2, 2021, 11:45:56 AM12/2/21
to AdWords API and Google Ads API Forum
Sent a "reply to author" with the requests for creating and updating the campaign. Let me know if you did not receive it as I cannot seem to figure out where the message is viewed.

Will Schymik

unread,
Dec 2, 2021, 2:37:56 PM12/2/21
to AdWords API and Google Ads API Forum
I am using the python SDK, and it seems as if when I specify manual_cpc on the campaign it does not appear on the field mask when I use the suggested protobuf_helpers.field_mask to construct it:

protobuf_helpers.field_mask(None, campaign._pb)

It does however appear in the resulting campaign_operation when I copy the update_mask into it. For example here is what the resulting operation looks like:

update {

  resource_name: "customers/REDACTED/campaigns/REDACTED"

  status: PAUSED

  manual_cpc {

    enhanced_cpc_enabled: false

  }

  dynamic_search_ads_setting {

  }

  name: "Test Campaign1638491806"

  campaign_budget: "customers/REDACTED/campaignBudgets/REDACTED"

}

update_mask {

  paths: "resource_name"

  paths: "name"

  paths: "status"

  paths: "campaign_budget"

}

Will Schymik

unread,
Dec 2, 2021, 3:48:21 PM12/2/21
to AdWords API and Google Ads API Forum
Seems as if the issue I am running into is the same one discussed in this post but for the python library: https://groups.google.com/g/adwords-api/c/GB4sReLzky4/m/_gk6ifgvBwAJ

Currently trying to figure out how to manually update the field mask to add these values. If anyone has any pointers as to how to do this in python I would appreciate it.

Will Schymik

unread,
Dec 3, 2021, 10:03:31 AM12/3/21
to AdWords API and Google Ads API Forum
Was able to update the field mask manually. Am running into issues clearing the bidding_strategy from the campaign. I had thought getting manual_cpc in the field mask might resolve this and is has not. I am getting the following response:

error_code {

    field_error: FIELD_CANNOT_BE_CLEARED

  }

  message: "The field cannot be cleared."

  location {

    field_path_elements {

      field_name: "operations"

      index: 0

    }

    field_path_elements {

      field_name: "update"

    }

    field_path_elements {

      field_name: "bidding_strategy"

Google Ads API Forum Advisor

unread,
Dec 3, 2021, 12:41:19 PM12/3/21
to will.s...@apartmentadvisor.com, adwor...@googlegroups.com
Hi Will,

Thank you for sharing your log privately. I replicated your issue using update_campaign.py. We have a guide to Setting Empty Message Objects as Fields that shows how to create a   manual_cpc strategy without enabling enhanced cpc. The modification I did based on that guide was I added underneath the line:
campaign.status = client.enums.CampaignStatusEnum.PAUSED

the lines:

manual_cpc = client.get_type('ManualCpc')
client.copy_from(campaign.manual_cpc,manual_cpc)

When I ran this the bidding strategy didn't change to a manual cpc and the update mask didn't register manual_cpc. When I used the following line unstead:

campaign.manual_cpc.enhanced_cpc_enabled = True

​​​​​​​The update mask had "manual_cpc.enhanced_cpc_enabled" in it. 

Let me bring this up with my team. We will get back to you a soon as possible.

Google Ads API Forum Advisor

unread,
Dec 3, 2021, 12:46:56 PM12/3/21
to will.s...@apartmentadvisor.com, adwor...@googlegroups.com
Hi Will, 

The 'bidding strategy' field is one of the possible union fields of campaign_bidding_strategy. That field can only be deleted by replacement with another of the union fields.

Will Schymik

unread,
Dec 3, 2021, 1:09:32 PM12/3/21
to AdWords API and Google Ads API Forum
Thanks for the response!

Setting "enhanced_cpc_enabled = True" does seem to add it to the field mask, however I was able to figure out how to do this manually. Even with it added to the field mask I am getting the issue with removing the bidding_strategy field as noted above.

In regards to "That field can only be deleted by replacement with another of the union fields." - the documentation shows that manual_cpc is another one of the union fields. Shouldn't I be able to remove bidding_strategy while I am setting manual_cpc?

My current request body that is getting the FIELD_CANNOT_BE_CLEARED response is:

  update {

    resource_name: "customers/REDACTED/campaigns/REDACTED"

    status: PAUSED

    manual_cpc {

      enhanced_cpc_enabled: true

    }

    dynamic_search_ads_setting {

    }

    name: "Test Campaign1638572728"

    campaign_budget: "customers/REDACTED/campaignBudgets/REDACTED"

  }

  update_mask {

    paths: "bidding_strategy"

    paths: "manual_cpc.enhanced_cpc_enabled"

  }

Google Ads API Forum Advisor

unread,
Dec 6, 2021, 7:50:45 PM12/6/21
to will.s...@apartmentadvisor.com, adwor...@googlegroups.com
Hello Will,

I'm checking with someone on the team to see if they know more about this.

Cheers,
 
Google Logo
Nadine Wang
Google Ads API Team
Reminder: Share your feedback about the Google Ads (AdWords) API! Take the 2021 Google Ads API and AdWords API Annual Survey


ref:_00D1U1174p._5004Q2Rw2hc:ref

Will Schymik

unread,
Dec 7, 2021, 9:19:20 AM12/7/21
to AdWords API and Google Ads API Forum
Thank you!

Will Schymik

unread,
Dec 7, 2021, 10:36:29 AM12/7/21
to AdWords API and Google Ads API Forum
I finally figured this out! The key is to not have "bidding_strategy" in the update mask and only "manual_cpc.enhanced_cpc_enabled". This seems to work.

For the python library I had to update the protobuf_helper.field_mask helper method to compare against None instead of the original object and then add "manual_cpc.enhanced_cpc_enabled" manually to the field mask using field_mask.paths.append as it does not appear there when "enhanced_cpc_enabled" is set to false or is not present.

The issue with "manual_cpc.enhanced_cpc_enabled" not appearing in the field mask should definitely be addressed. 

Cheers!

Google Ads API Forum Advisor

unread,
Dec 10, 2021, 11:34:19 AM12/10/21
to will.s...@apartmentadvisor.com, adwor...@googlegroups.com

Hi Will,

Thanks for letting us know. Nadine passed this issue along to me as I'm the maintainer of the Python client library. I see you also posted a related issue to that repo, which is great, I'll respond there as well. Meanwhile will let you know that this is a known behavior of the field mask helper. When comparing two protobuf messages to generate field mask, the field mask helper can't tell the difference between a field that is not set, and a field is set to its default value (i.e. 0 is the default for most numeric fields). So in such a case, you would need to manually append this field to the field mask. 

I noticed that our documentation doesn't specify this, so I'll get this updated ASAP.

Thanks!
Ben, Google Ads API Team



ref:_00D1U1174p._5004Q2Rw2hc:ref

Will Schymik

unread,
Dec 10, 2021, 11:45:47 AM12/10/21
to AdWords API and Google Ads API Forum
Thanks Ben!

Adding the field mask appending to the documentation would be awesome.

It also seems odd to me that using the old campaign as the base object in the field mask helper caused issues. I would expect this is the intended way of creating a field mask (comparing the new values to old values), however in this case the API was resistant to the explicit removal of the bidding_strategy field even though another one of the unioned fields was added. I would expect this might be more of an issue with the API that isn't worth addressing explicitly in the SDK?

Will

Google Ads API Forum Advisor

unread,
Dec 10, 2021, 1:33:23 PM12/10/21
to will.s...@apartmentadvisor.com, adwor...@googlegroups.com
Hey Will,

Yes, the field mask helper is actually pretty simple. You can also pass None as one of the paramters, and it will compare the other object to a blank version of the same type. I just did some simple experimentation and it doesn't seem as though it handles oneof fields (like bidding strategy) very well. For example, if I compare a campaign with manual_cpc.enhanced_cpc_enabled = True to another campaign with manual_cpm set to {} it doesn't acknowledge the change in field, it just seems to think that manual_cpc has been unset. 

In general the way to unset any field (in your case, to remove the resource name for a portfolio bidding strategy) is to leave the field blank and manually add the field to the update_mask. The API will see that you intend to update that field, see that it's blank, and assume you meant to return it to it's default value, in this case an empty string. At some point in the distant future I'd like for the update_mask logic to be more implicit and require no manual intervention, but that's unlikely to happen any time soon.

If you have any more questions or issues related to this, please feel free to add another issue to the GitHub repo.

Thanks,
Reply all
Reply to author
Forward
0 new messages