What should I send to the AdGroupAdService if I want to create an Image Ad?

27 views
Skip to first unread message

Farid el Nasire

unread,
Nov 4, 2016, 10:38:57 AM11/4/16
to AdWords API Forum

The documentation is slightly cryptic when it comes to this field and there are no examples available anywhere. I've used the MediaService to upload an image to AdWords, I got a mediaId  back, I now want to "bind it" to an ad. With a text ad I used to send the following ADD operation:

{
   
'operator': 'ADD',
   
'operand': {
       
'xsi_type': 'AdGroupAd',
       
'adGroupId': arg['adgroup_id'],
       
'ad': {
           
'xsi_type': 'TextAd',
           
'finalUrls': [arg['final_url']],
           
'displayUrl': arg['display_url'],
           
'description1': arg['description1'],
           
'description2': arg['description2'],
           
'headline': arg['headline']
       
},
       
'status': 'ENABLED'
   
}
}

What do I send if I want to use the uploaded image with an ad? Specifically the "Image" field is a bit uncertain.

Shwetha Vastrad (AdWords API Team)

unread,
Nov 4, 2016, 2:06:54 PM11/4/16
to AdWords API Forum
Hi Farid,

You need to add an ImageAd and provide the MediaId of the image you uploaded in the Image.mediaId field. The ADD operation would look like:

      {
          'operator': 'ADD',
          'operand': {
              'xsi_type': 'AdGroupAd',
              'adGroupId': ad_group_id,
              'ad': {
                  'xsi_type': 'ImageAd',
                  'finalUrls': [arg['final_url']],
                  'displayUrl': arg['display_url'],
                  'name': 'ad_name',
                  'image': {
                   'mediaId': media_id
                  }
              },
              # Optional fields.
              'status': 'ENABLED'
          }
      }

Regards,
Shwetha, AdWords API Team.
Reply all
Reply to author
Forward
0 new messages