Use Image Ad thumbnail in Drive Sheet?

54 views
Skip to first unread message

Jon Gritton

unread,
Jul 18, 2018, 12:48:52 PM7/18/18
to AdWords Scripts Forum
Hi all, I've had a request to build a report in a Drive Sheet that shows a thumbnail of the associated image Ad in the row.  Before I spend hours trying to do this, does anyone know if it's possible to get hold of the image used in an Ad in any format that could be inserted into a sheet cell?

Jon

Anthony Madrigal

unread,
Jul 18, 2018, 4:00:14 PM7/18/18
to AdWords Scripts Forum
Hi Jon,

Yes, this is possible. You can retrieve an image ad's preview URL via the getURLs() method.

For example, after filtering your ads with the condition for ads with images, you could use the following line of code:

var previewImageURL= ad.asType().imageAd().getImage().getUrls().getPreviewUrl();

You can use this preview image URL in conjunction with SpreadSheetApp's sheet class to call the method, insertImage, and use the previewImageURL value as an argument.

Let us know if you have any other questions on this.

Cheers,
Anthony
AdWords Scripts Team

Jon Gritton

unread,
Jul 23, 2018, 1:05:56 PM7/23/18
to AdWords Scripts Forum
Hi Anthony, thanks for the help - that works fine!  However, I've a couple of problems - one related to the image, one not, and I'd be grateful if you could help again!

The sheet is supposed to hold "current" data for each Ad, so as part of the script process I'm clearing all previous data content before writing out today's figures.  This works fine for the text/numerical data but clear() seems to ignore the images, meaning that each run inserts another image in the same place.  Is there a method to clear image content on the sheet?

The other problem I'm having is that sort() doesn't seem to be working - I've tried for a while now with all formats, and with ascending booleans/and not, etc. and the data seems totally unaffected.  Any ideas?

Many thanks, 

Jon

Anthony Madrigal

unread,
Jul 23, 2018, 2:54:23 PM7/23/18
to AdWords Scripts Forum
Hi Jon,

I was able to see the behavior with the spreadsheet not clearing the images. You can find ways to sort your sheets by using these functions.

Since the issues are SpreadsheetApp related, I'd recommend reaching out to the Apps Script Team since they may have ideas on how to resolve these.

Regards,
Anthony
AdWords Scripts Team
Reply all
Reply to author
Forward
0 new messages