Script | PMax - Removing Automatically Generated Videos

2,250 views
Skip to first unread message

Aysenin Ulker

unread,
Jan 17, 2023, 11:07:53 PM1/17/23
to Google Ads Scripts Forum
Hey, 

I am trying to remove YouTube videos that are automatically created within Performance Max campaigns by running the following 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")
 }
}

It gives me an error message which says basically that Google's encountered a problem. See screenshot attached.

Immagine 2023-01-17 180617.png

How can I solve this issue?

Thanks

Sigurd Fabrin

unread,
Jan 18, 2023, 5:35:35 AM1/18/23
to Google Ads Scripts Forum
Same issue here "An error occurred. Please try again later."

The: removeAsset(asset, fieldType) doesn't seem to work
It fails with all the different AssetFieldTypes


sigurd

Google Ads Scripts Forum Advisor

unread,
Jan 19, 2023, 2:19:51 AM1/19/23
to adwords...@googlegroups.com

Hello everyone,

I’m James from the Google Ads scripts support team. Thank you for reaching out to us.

Could you please provide us with the following items below so that we can check and verify the issue first?

  • Google Ads account ID or CID
  • Name of the script wherein the given code snippet is implemented.

Regards,

Google Logo
James Howell
Google Ads Scripts Team
 


ref:_00D1U1174p._5004Q2hzimn:ref

Sigurd Fabrin

unread,
Jan 19, 2023, 5:53:33 AM1/19/23
to Google Ads Scripts Forum
I don't have permission cannot reply private in the group

However, here's the script so you can see if it will work in your end:

// Attempt to remove (automatically created) youtube videos (or any other asset type) from Performance Max
// Part that doesn't work: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_assetgroup#removeAsset_2
// Script is from https://sem-bg.medium.com/script-that-deletes-automatically-created-youtube-videos-in-perfomance-max-campaigns-ae40895f96ac

   
 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();
   
  // "An error occurred. Please try again later." Same with any asset type
  // https://developers.google.com/google-ads/api/reference/rpc/v12/AssetFieldTypeEnum.AssetFieldType

   assetGroup.removeAsset(asset_for_delete,'YOUTUBE_VIDEO');

   Logger.log("Campaign: "+performanceMaxCampaign.getName() + " | Asset group: "+assetGroup.getName() + " asset ID: "+row['asset.id']) 
 }



sigurd

Aysenin Ulker

unread,
Jan 19, 2023, 7:15:36 AM1/19/23
to Google Ads Scripts Forum
Hi James,

Name of the script: FIND_Rimozione_asset_video_automatici
Account: 499-302-8161

Let me know,

Thanks,

Aysenin

Lyubomir Popov

unread,
Jan 19, 2023, 8:17:25 AM1/19/23
to Google Ads Scripts Forum
I'm the author of the script.
I confirm that the script WAS WORKING, BUT IT STOPPED WORKING few days ago.
assetGroup.removeAsset DOES NOT WORKING for YOUTUBE_VIDEO  asset type (whatever the asset.source is)
Please don't ask for ID or script name. It's not working across 200 accounts ...

Google Ads Scripts Forum

unread,
Jan 19, 2023, 9:57:58 PM1/19/23
to Google Ads Scripts Forum
Reposting the last inquiry (https://groups.google.com/g/adwords-scripts/c/bRc25FBxFMo) from the forum as it wasn't routed to our support queue.

Regards,
Yasmin
Google Ads Scripts Team

Google Ads Scripts Forum Advisor

unread,
Jan 20, 2023, 1:43:30 AM1/20/23
to adwords...@googlegroups.com

Hi All,

 

Yasmin here from the Google Ads Scripts Team. Thank you for your combined effort in providing information and additional context to this.

 

Allow me to raise this to our internal team in order to be further investigated. Rest assured that we'll get back to you the soonest we do receive a response with relevant information from them.

 

Best regards,

 

Google Logo
Yasmin Gabrielle
Google Ads Scripts Team
 


ref:_00D1U1174p._5004Q2hzimn:ref

Colleen

unread,
Feb 6, 2023, 9:06:52 AM2/6/23
to Google Ads Scripts Forum
Hi Yasmin,

Any updates on this?

Thanks,
Colleen

Google Ads Scripts Forum

unread,
Feb 7, 2023, 7:22:14 AM2/7/23
to Google Ads Scripts Forum
Reposting the last inquiry (https://groups.google.com/g/adwords-scripts/c/bRc25FBxFMo) from the forum as it wasn't routed to our support queue.

Regards,
Yasmin
Google Ads Scripts Team

Google Ads Scripts Forum

unread,
Feb 7, 2023, 7:24:00 AM2/7/23
to Google Ads Scripts Forum
Hi Colleen,

I'm afraid we don't have any updates to share with you yet. While we do appreciate your patience on this so far, I'll follow up on this and get back the soonest we do get a response with relevant information.

Best regards,

Yasmin
Google Ads Scripts Team

Lyubomir Popov

unread,
Feb 13, 2023, 8:02:22 AM2/13/23
to Google Ads Scripts Forum
I'm sure that it the functionality to remove automatically created video has been REMOVED ON PURPOSE. There is no bug there. Everything has been done ON PURPOSE...

Hamza Al-sayyed

unread,
Feb 13, 2023, 8:04:06 AM2/13/23
to Google Ads Scripts Forum

off course there is no bug, 

Lyubomir Popov

unread,
Feb 13, 2023, 8:15:14 AM2/13/23
to Google Ads Scripts Forum
I published my script on 13 of December 2022 here https://sem-bg.medium.com/script-that-deletes-automatically-created-youtube-videos-in-perfomance-max-campaigns-ae40895f96ac
Two weeks later it stopped working.
Two months later nobody can fix it :)
Tell me that I'm wrong :)

Hamza Al-sayyed

unread,
Feb 13, 2023, 8:36:09 AM2/13/23
to Google Ads Scripts Forum
Unfortunately we can't do anything for this situation all we have to do is to find a new solution, 

And sometimes this information might be so critical to be shared with people, once google team notice that there  is something can  Improve the performance they will remove it immediately 

I hope google team will fix this and give the advertisers some space and control.

The algorithm is smart and good but still Human brains is the greatest.

Google Ads Scripts Forum Advisor

unread,
Feb 14, 2023, 4:03:07 AM2/14/23
to adwords...@googlegroups.com

Hi All,

 

Thank you for all of your insights on this. There was a lengthy investigation conducted on this issue by our internal team which I'll be summarizing below:

 

It appears that this has been concluded to be intended behaviour due to a recent change in the Google Ads API. System generated asset links shouldn't be able to be removed 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 for future announcements and latest updates.

 

You may check the below relevant links:

Lyubomir Popov

unread,
Feb 14, 2023, 7:11:08 AM2/14/23
to Google Ads Scripts Forum
So, the case is closed... As usually with: "Working as intended' or "Expected behavior" :) :)

Google Ads Scripts Forum

unread,
Mar 31, 2023, 7:13:20 AM3/31/23
to Google Ads Scripts Forum
Reposting the last inquiry (https://groups.google.com/g/adwords-scripts/c/bRc25FBxFMo) from the forum as it wasn't routed to our support queue.

Regards,
Google Ads Scripts Team
Reply all
Reply to author
Forward
0 new messages