Creating Responsive display ads with google ads api

937 views
Skip to first unread message

Vinutha Nayak

unread,
May 22, 2019, 3:35:00 PM5/22/19
to AdWords API and Google Ads API Forum
Has anyone tried creating ResponsiveDisplayAds with google ads api ?  I am using python and having a tough time. There are no samples as well.

I was able to create the adgroup. I am doing the following :


ad_group_ad_service = client.get_service('AdGroupAdService', version='v1')
ad_group_service = client.get_service('AdGroupService', version='v1')

# Create ad group ad.
ad_group_ad_operation = client.get_type('AdGroupAdOperation', version='v1')
ad_group_ad = ad_group_ad_operation.create
ad_group_ad.ad_group.value = ad_group_service.ad_group_path(customer_id, adgroup_id)
ad_group_ad.status = client.get_type('AdGroupAdStatusEnum',version='v1').PAUSED


## setting variable values.
ad_group_ad.ad.responsive_display_ad.marketing_images.asset.value = '<image name>'
ad_group_ad.ad.responsive_display_ad.headlines.text.value = "headline1 text"
ad_group_ad.ad.responsive_display_ad.headlines.pinned_field = client.get_type('ServedAssetFieldTypeEnum',version='v1').HEADLINE_1
ad_group_ad.ad.long_headline.text.value = "long_headline text "
ad_group_ad.ad.long_headline.pinned_field = client.get_type('ServedAssetFieldTypeEnum',version='v1').HEADLINE_2
ad_group_ad.ad.descriptions.text.value = " Descriptions text "
ad_group_ad.ad.descriptions.pinned_field = client.get_type('ServedAssetFieldTypeEnum', version='v1').DESCRIPTION_1
ad_group_ad.ad.business_name.value = "Buisness name text "


I see the following error :

    ad_group_ad.ad.responsive_display_ad.marketing_images.asset.value = 'Image Name'
AttributeError: 'google.protobuf.pyext._message.RepeatedCompositeCo' object has no attribute 'asset'


I am unable to understand what is going wrong. Can anyone please help ?
Also where do we specify the complete path of the image to  upload it.



Google Ads API Forum Advisor Prod

unread,
May 22, 2019, 11:56:51 PM5/22/19
to adwor...@googlegroups.com

Hi,

Thank you for reaching out. Since you want to create a ResponsiveDisplayAds, you may refer this sample code for creating expanded text ads. You just need to replace the expanded_text_ad to responsive_display_ad. Additionally, these are the fields that can be populated with responsive display ad.

Let me know if this helps. Feel free to write back if you have further clarifications.

Regards,
Dave
Google Ads API Team



ref:_00D1U1174p._5001UAqMsW:ref

Vinutha Nayak

unread,
May 23, 2019, 1:22:58 AM5/23/19
to AdWords API and Google Ads API Forum
Hi, 

I have checked the code for creating expanded text ads and also the fields to be populated for responsive display ads.  For expanded text ads, mostly it is direct assignment for string values.  However,  the parameters are totally different when it comes to Responsive display ads. 

Hence my query is specifically on responsive display ads. Could you please provide a  code snippet  or direct me to any sample code that has particularly responsive display ads. 

I have searched through enough in all ways possible, and I don't see ANY  help on the same  for python.


Thanks and Regards,
Vinutha

Google Ads API Forum Advisor Prod

unread,
May 23, 2019, 6:23:03 AM5/23/19
to adwor...@googlegroups.com

Hi,

Unfortunately, there isn't any sample code that is particular for creating responsive display ads yet. As I have said, you may refer to the sample code for expanded text ads as it is almost the same with responsive display ads. You need only to replace expanded text ads fields with responsive display ads fields and you can refer to the documentation to determine which fields are required.



Regards,
Dave
Google Ads API Team



ref:_00D1U1174p._5001UAqMsW:ref

Vinutha Nayak

unread,
May 23, 2019, 8:08:59 AM5/23/19
to AdWords API and Google Ads API Forum
Hi Dave,
Sorry, but I don't think that is a suitable response. It is disappointing and defeats the very essence of asking something in the forum.

As I said I have done all the due diligence before asking the question on forum. Also it is not a direct one to one replacement that can be done looking at expanded text ads. Considering I have provided the snippet I have tried and failed is there no one who can validate and correct it? Only hope asking something out here is that there are people in the other end who can advise above the docs?

Hopefully that stands true here.
Thanks and Regards,
Vinutha

Google Ads API Forum Advisor Prod

unread,
May 24, 2019, 4:05:44 AM5/24/19
to adwor...@googlegroups.com
Hi Vinutha,

My apologies for the inconvenience of having no current guides or examples specific to the Google Ads API. However, you may note that the service names and fields involved in creating the ResponsiveDisplayAd in the Google Ads API is still similar to the ones used in the old AdWords API.

You can refer to this Python example from the old AdWords API and you can use the Google Ads API's AdGroupAdService (MutateAdGroupAds method) and to the ResponsiveAdDisplayInfo object to see which fields you can set.

Feel free to write back if you have any further clarifications.

Thanks and regards,
Peter

Vinutha Nayak

unread,
May 24, 2019, 4:33:00 AM5/24/19
to AdWords API and Google Ads API Forum
Hi Peter,

As I have told, I have searched everywhere possible and the link that you have given me is from AdwordsAPI and I am using googleAds api .. it is totally different and cannot be used and referred to as a replacement for another. 

I did some more trial and error and I tried this ;

resp_image =  ad_group_ad.ad.responsive_display_ad.marketing_images.add()
resp_image.asset.value = 'Landscape Image'

I am getting  following error with this :

[2019-05-24 12:37:39,834 - WARNING] Request made: ClientCustomerId: , Host: googleads.googleapis.com:443, Method: /google.ads.googleads.v1.services.AdGroupAdService/MutateAdGroupAds, RequestId: 5EIz_vb9mEhLlTLm0P
HYbQ, IsFault: True, FaultMessage: Resource name 'Landscape Image' is malformed: expected 'customers/{customer_id}/assets/{part_1}'.
Request with ID "5EIz_vb9mEhLlTLm0PHYbQ" failed with status "INVALID_ARGUMENT" and includes the following errors:
        Error with message "Resource name 'Landscape Image' is malformed: expected 'customers/{customer_id}/assets/{part_1}'.".
                On field: operations
                On field: create
                On field: ad
                On field: responsive_display_ad
                On field: marketing_images
                On field: asset

If I check the adImageAsset  link https://developers.google.com/google-ads/api/reference/rpc/google.ads.googleads.v1.common#google.ads.googleads.v1.common.AdImageAsset.   It is a StringValue,  but it still  gives the same error. 

Is there anyone who can review the python code and point what's wrong ? 

Thanks and Regards,
Vinutha

Google Ads API Forum Advisor Prod

unread,
May 24, 2019, 12:33:32 PM5/24/19
to nayakv...@gmail.com, adwor...@googlegroups.com
Hi Vinuntha!

Thanks for the question and apologies for the prolonged back and forth.

The asset field on an AdImageAsset is indeed a StringValue so you're setting it correctly in your code snippet. However the string itself is not arbitrary, it must be the resource_name of an existing Asset. Note the statement in the error message: Resource name 'Landscape Image' is malformed: expected 'customers/{customer_id}/assets/{part_1}'." And recall that a resource_name is similar to the id of an entity, so you're specifying an individual Asset entity as one of the marketing images on the ad.

You can use the below select statement in search query to find Assets in your account that meet the criteria for marketing_images in a responsive_display_ad. If this query does not return any results you'll need to add images using the AssetService.

Hope that helps!

Best,
Ben Karl, Google Ads API Team

SELECT
  asset.resource_name,                                                          
  asset.image_asset.full_size.height_pixels,                                    
  asset.image_asset.full_size.width_pixels,                                     
  asset.image_asset.mime_type                                                   
FROM asset                                                                      
WHERE                                                                           
  asset.image_asset.mime_type IN (IMAGE_JPEG, IMAGE_PNG, IMAGE_GIF) AND         
  asset.image_asset.full_size.height_pixels >= 314 AND                          
  asset.image_asset.full_size.width_pixels >= 600     


ref:_00D1U1174p._5001UAqMsW:ref

Vinutha Nayak

unread,
May 26, 2019, 9:58:54 AM5/26/19
to AdWords API and Google Ads API Forum
Hi Ben,

Thanks for the clear explanation .That really helps!!!!

I haven't been able to add successfully an image asset yet, but  at least I know what needs to be done and why the error . Let me try few things out before I get back to you again.


Thanks and Regards,
Vinutha

Google Ads API Forum Advisor Prod

unread,
May 28, 2019, 7:55:03 AM5/28/19
to nayakv...@gmail.com, adwor...@googlegroups.com
Hi Vinutha,

Sounds good, thank you for letting me know.

Best,
Ben, Google Ads API Team

ref:_00D1U1174p._5001UAqMsW:ref

Vinutha Nayak

unread,
May 28, 2019, 9:50:56 AM5/28/19
to AdWords API and Google Ads API Forum
Hi  Ben,

I have been finally been able to add  Image.  :) . Thanks a lot !

Thanks and Regards,
Vinutha Nayak

Google Ads API Forum Advisor Prod

unread,
May 28, 2019, 12:24:25 PM5/28/19
to nayakv...@gmail.com, adwor...@googlegroups.com
Wonderful! Happy to help!
Reply all
Reply to author
Forward
Message has been deleted
0 new messages