Error: Remove YouTube videos automatically created within Performance Max

118 views
Skip to first unread message

Carmine D'Alessio

unread,
May 25, 2023, 9:40:55 AM5/25/23
to Google Ads Scripts Forum
when i run this script i get the following error: An error has occurred. Try later.

Script:

function main()

{

 var aAssets = [];

 var aAsset_gorup = [];

 var aPMax = [];

 

 var Query= "SELECT campaign.id, asset_group.id, asset.id, asset_group_asset.field_type "+

         "FROM asset_group_asset "+

         "WHERE asset_group_asset.field_type = 'YOUTUBE_VIDEO' "+

         "AND asset.source = 'AUTOMATICALLY_CREATED' "+

         "AND asset_group_asset.status = 'ENABLED' "+

         "AND campaign.status = 'ENABLED'";

 

 var rep = AdsApp.report(Query);

 var rows = rep.rows();

 while (rows.hasNext())

 {

   var row = rows.next();

 

   var performanceMaxCampaign = AdsApp.performanceMaxCampaigns().withIds([row['campaign.id']]).get().next();

   var assetGroup = performanceMaxCampaign.assetGroups().withIds([row['asset_group.id']]).get().next();

   var asset_for_delete = AdsApp.adAssets().assets().withIds([row['asset.id']]).get().next();   

   assetGroup.removeAsset(asset_for_delete,'YOUTUBE_VIDEO');

   Logger.log("Campaign: "+performanceMaxCampaign.getName() + " | Asset group: "+assetGroup.getName() + " - аutomatically created video has been removed")

 }

}


Google Ads Scripts Forum Advisor

unread,
May 29, 2023, 3:59:47 AM5/29/23
to adwords...@googlegroups.com

Hi Carmine,

 

Thank you for reaching out to the Google Ads Scripts Forum Channel.

 

Kindly note that, due to a change in the Google Ads API <https://developers.google.com/google-ads/api/docs/start>, it's not possible to remove system generated asset links in the API. Our team is planning to release a blog post regarding this, but this would also be the information that would be announced. I would recommend to instead keep an eye on our Ads Developer Blog <https://ads-developers.googleblog.com/search/label/google_ads_scripts> for future announcements and latest updates.

 

You may check the below relevant links:

 

Let us know if we can assist you with anything else.

 

This message is in relation to case "ref:_00D1U1174p._5004Q2ltFrB:ref"

Thanks,
 
Google Logo Google Ads Scripts Team


Reply all
Reply to author
Forward
0 new messages