PHP: How to add a video to a Gmail Ad?

36 views
Skip to first unread message

Noam Alloush

unread,
May 27, 2020, 2:17:19 AM5/27/20
to AdWords API and Google Ads API Forum
This is my code and I don't understand what is wrong here:
$videoURL = new Video();
$videoURL->setMediaId('zcs2xAXXaZw');

// Creates a Gmail ad.
$gmailAd = new GmailAd();
$gmailAd->setTeaser($teaser);
$gmailAd->setProductVideoList([$videoURL]);
$gmailAd->setMarketingImage($marketingImage);
$gmailAd->setMarketingImageHeadline($ad_headlines[0]);
$gmailAd->setMarketingImageDescription($ad_Descriptions[0]);
$gmailAd->setFinalUrls(array(FixFinalUrl($extURL,$customH1title,'')));

When I remove this line:
$gmailAd->setProductVideoList([$videoURL]);
Every thing is working good of-course.

And this is the error I'm getting:
operations[25].operand.ad.productVideoList[0].mediaId
RequiredError.REQUIRED

Thanks

Google Ads API Forum Advisor Prod

unread,
May 27, 2020, 2:01:55 PM5/27/20
to no...@camelengine.com, adwor...@googlegroups.com
Hi Noam,

Thank you for reaching out to us. I see that you're encountering an issue uploading videos to Gmail Ads. Could you please provide us with the full request and response logs for where this error occurs so that I may further assist you? 

Thank you,
Bryan, Google Ads API Team

ref:_00D1U1174p._5004Q1zsBQJ:ref

Noam Alloush

unread,
May 27, 2020, 11:59:28 PM5/27/20
to AdWords API and Google Ads API Forum
Hi Bryan,

I posted on my first post. I think it's related to the way I setup the video ID.
Take a look on the code

Google Ads API Forum Advisor Prod

unread,
May 28, 2020, 3:00:22 PM5/28/20
to no...@camelengine.com, adwor...@googlegroups.com
Hi Noam,

I took a look at the error message and looked at the structure of Gmail Ads and it looks like in order to upload a video to your Gmail ad, it must be a YouTube hosted video and mediaId must be populated. Therefore, you'll need to populate and set the mediaID for the video to upload this video. Let me know if you have further concerns.
Reply all
Reply to author
Forward
0 new messages