How to stop serving ad asset (remove link to asset) using google api
I need to make inactive assets linked to a specific ad, i.e. to get the same result through the api as in the google ads web interface. Example by following the link
I've tried it myself in two ways
- I wanted to try and delete the asset itself, but I found a description in the documentation that the asset cannot be deleted using AssetService because it does not support a remove operation
- Ok, I tried to remove an ad using AdGroupAdService using sample (using python but this is not crucial) but got an message about this operation not for an ad with type APP_AD message: "Cannot remove an adgroup ad with this ad type."
In the end, I found information that in order to stop an asset, the link between the asset and the ad has to be removed. But nowhere is there any example of what this is or how to do it. Any help with this problem would be greatly appreciated.
Assuming you already know resource name:
def remove_asset_from_campaign(customer_id, resource_name): """Removes asset (e.g. sitelink) identified by resource_name from campaign. """ campaign_asset_service = client.get_service("CampaignAssetService") campaign_asset_operation = client.get_type("CampaignAssetOperation") campaign_asset_operation.remove = resource_name campaign_asset_response = campaign_asset_service.mutate_campaign_assets( customer_id=customer_id, operations=[campaign_asset_operation] ) print( "Campaign criterion with resource name " f'"{campaign_asset_response.results[0].resource_name}" was ' "modified." )