Image doesn't display when creating gmail ad via API

22 views
Skip to first unread message

James Huang

unread,
Dec 17, 2017, 10:48:41 AM12/17/17
to AdWords API Forum
I have tried added both image gmail ads and multi-product gmail ads into a standard display campaign and the ads were created successfully however whenever I previewed the result, only the subject, logo and description were displayed, and the main visual image or the multi-product image don't display at all. Followings are the python code I used. Could you help confirm whether it's an issue of my API request or API itself. Many thanks.

def _CreateImagedata(url):
"""Creates an image and uploads it to the server.
Args:
media_service: a SudsServiceProxy instance for AdWords's MediaService.
opener: an OpenerDirector instance.
url: a str URL used to load image data.
Returns:
The image that was successfully uploaded.
"""
media_service = adwords_client.GetService('MediaService', version='v201708')
opener = urllib.request.build_opener(*adwords_client.proxy_config.GetHandlers())
image_data = base64.b64encode(opener.open(url).read()).decode('utf-8')
image = {
'type': 'IMAGE',
'data': image_data,
'xsi_type': 'Image',
}
uploaded_image = media_service.upload(image)[0]
image_uploaded = {
'type': 'IMAGE',
'mediaId': uploaded_image['mediaId'],
'xsi_type': 'Image',
}

return image_uploaded

def main(client, ad_group_id):
# Initialize appropriate service.
ad_group_ad_service = client.GetService('AdGroupAdService', version='v201710')

ad_data = {
'uniqueName': 'adData',
'fields': [
{
'name': 'logo',
'fieldMedia': _CreateImagedata('<my logo image URL>'),
'type': 'IMAGE'
},
{
'name': 'advertiser',
'fieldText': '<my brand>',
'type': 'TEXT'
},
{
'name': 'subject',
'fieldText': '<my subject>',
'type': 'TEXT'
},
{
'name': 'description',
'fieldText': '<My description>',
'type': 'TEXT'
},
{

'name': 'image',
'fieldMedia': _CreateImagedata('<image URL of main visual>'),
'type': 'IMAGE'
}
]
}

#https://developers.google.com/adwords/api/docs/appendix/templateads
gmail_product_ad = {
'xsi_type': 'TemplateAd',
'name': 'Gmail product ad',
'templateId': 459, #466 gmail multi-product ad, 459 Gmail image template
'finalUrls': ['<my final URL>'],
'displayUrl': '<my display URL)',
'templateElements': [ad_data],
}

ad_group_ad = {
'adGroupId': ad_group_id,
'ad': gmail_product_ad,
'status': 'PAUSED'
}

operations = [
{
'operator': 'ADD',
'operand': ad_group_ad
}
]
ads = ad_group_ad_service.mutate(operations)

Vincent Racaza (AdWords API Team)

unread,
Dec 18, 2017, 1:41:46 AM12/18/17
to AdWords API Forum
Hi James,

Can you provide to me the SOAP request and response logs generated when you created the template ads? Also, can you confirm if what you meant by the "image doesn't display", is that it does not display in the AdWords UI? If so, please provide a UI screenshot of this template ad on which the image does not display. Kindly use the Reply privately to author option when replying.

Thanks,
Vincent
AdWords API Team
Reply all
Reply to author
Forward
0 new messages