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)
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+:
https://googleadsdeveloper.blogspot.com/
https://plus.google.com/+GoogleAdsDevelopers/posts
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
You received this message because you are subscribed to the Google
Groups "AdWords API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
---
You received this message because you are subscribed to the Google Groups
"AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
Visit this group at https://groups.google.com/group/adwords-api.
To view this discussion on the web visit
https://groups.google.com/d/msgid/adwords-api/429f26e0-aa32-49e9-bd12-45d4c7f22cbb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.