asset_link_error when trying to ad image asset to adgroup in google ads api (php)

200 views
Skip to first unread message

Shawn Naquin

unread,
Oct 31, 2021, 1:23:13 PM10/31/21
to AdWords API and Google Ads API Forum
When I try to link an image asset to an AdGroup in php with the Google Ads PHP library I get the message:

(php 7.4, google-ads-api v8, grpc with composer library googleads/google-ads-php ^12)

asset_link_error: The given field type is not supported to be added directly via asset links.

The below code is taken straight from the docs

// create & upload the asset
$imageAsset = new Asset(
    [
        'name' => $imageUrl,
        'type' => AssetType::IMAGE,
        'image_asset' => new ImageAsset(
            [
                'data' => file_get_contents($imageUrl)
            ]
        )
    ]
);

...after sending the creation as an operation, the asset creation is then sent successfully, and I can successfully query for the newly created asset.

// Creates an operation to add the asset to the adgroup.
$adGroupAsset = new AdGroupAsset(
[
    'ad_group' => $adGroupResourceName,
    'asset' => $assetResName,
    'field_type' => AssetFieldType::MARKETING_IMAGE,
    'status' => AssetLinkStatus::ENABLED,
]
);

$adGroupAssetOperation = new AdGroupAssetOperation();
$adGroupAssetOperation->setCreate($adGroupAsset);

$adGroupAssetServiceClient = $this->googleAdsClient->getAdGroupAssetServiceClient();
$response = $adGroupAssetServiceClient->mutateAdGroupAssets(
    $this->clientId,
    [$adGroupAssetOperation]
);

I checked, and I can add an image link manually to this same adgroup in the UI!

Any help would be appreciated, there's not much info about this error in the docs or how to go about adding image extensions to an adgroup.

Thanks,
Shawn

Google Ads API Forum Advisor

unread,
Nov 2, 2021, 2:49:06 AM11/2/21
to sna...@themorangroup.net, adwor...@googlegroups.com
Hi Shawn,

Thank you for reaching out to our API support team.

Could you confirm if what you intend to do is use assets in ads? If yes then the link you provided should indeed be the appropriate guide.

However, since you appear to be using the AdGroupAssetService, then its typical usage is for creating asset based extensions as discussed here

Best regards,

Google Logo
Peter Laurence Napa Oliquino
Google Ads API Team
 


ref:_00D1U1174p._5004Q2QGllD:ref

Shirly J

unread,
Nov 22, 2021, 4:42:36 AM11/22/21
to AdWords API and Google Ads API Forum
Hi,

I am trying to do the same(adding image extension to adgroup).

//adgroupassetOperation
$adGroupAssetOperation = new AdGroupAssetOperation([
'create' => new AdGroupAsset([
'asset' => $imageAssetResourceName,
'field_type' => AssetFieldType::MARKETING_IMAGE,
'ad_group' => ResourceNames::forAdGroup($clientId, $adGroupId)
])
]);

$adGroupAssetServiceClient = $this->googleAdsClientSession->getAdGroupAssetServiceClient();
$response = $adGroupAssetServiceClient->mutateAdGroupAssets($clientId, [$adGroupAssetOperation]);

I am getting the same error : The given field type is not supported to be added directly via asset links.
assetLinkError: UNSUPPORTED_FIELD_TYPE
stringValue: MARKETING_IMAGE

could anyone help?

Thanks

Google Ads API Forum Advisor

unread,
Nov 22, 2021, 3:46:38 PM11/22/21
to pons...@gmail.com, adwor...@googlegroups.com
Hi Shirley,

Please note that the CampaignAsset, AdGroupAsset and CustomerAsset works only for assets that are associated with an Extension.

Reminder: Share your feedback about the Google Ads (AdWords) API! Take the 2021 Google Ads API and AdWords API Annual Survey
 
Regards,
Google Logo
Aryeh Baker
Google Ads API Team
 


ref:_00D1U1174p._5004Q2QGllD:ref
Message has been deleted

Shirly J

unread,
Nov 23, 2021, 7:41:26 AM11/23/21
to AdWords API and Google Ads API Forum

Hi Aryeh,

Thank you for the information. I have followed the same documentation. But getting the same error

1. Create ImageAsset for ImageExtension

// Creates an asset.
$asset = new Asset([
'type' => AssetType::IMAGE,
'image_asset' => new ImageAsset(['data' => $imageContent])
]);

// Creates an asset operation.
$assetOperation = new AssetOperation();
$assetOperation->setCreate($asset);

// Issues a mutate request to add the asset.
$assetServiceClient = $this->googleAdsClientSession->getAssetServiceClient();
$response = $assetServiceClient->mutateAssets(
$clientId,
[$assetOperation]
);
if (!empty($response->getResults())) {
$addedImageAsset = $response->getResults()[0];
return $addedImageAsset->getResourceName();
}

2. Add asset to AdGroup

//adgroupassetOperation
$adGroupAssetOperation = new AdGroupAssetOperation([
'create' => new AdGroupAsset([
'asset' => $imageAssetResourceName,
'field_type' => AssetFieldType::MARKETING_IMAGE,
'ad_group' => ResourceNames::forAdGroup($clientId, $adGroupId)
])
]);

$adGroupAssetServiceClient = $this->googleAdsClientSession->getAdGroupAssetServiceClient();
$response = $adGroupAssetServiceClient->mutateAdGroupAssets($clientId, [$adGroupAssetOperation]);

Could you please point out what is missing?

Thanks

Google Ads API Forum Advisor

unread,
Nov 23, 2021, 9:23:21 PM11/23/21
to pons...@gmail.com, adwor...@googlegroups.com
Hi Shirly,

Thank you for providing additional details.

Image assets can be set for certain types of ads, as seen here. However, it currently cannot be used for extensions.

Listed here are the asset based extensions that are currently supported and can be created/managed via the API, and stating that other types would follow later. For now, you may keep an eye on our blog for updates or announcements on when image extensions can be included.

If you wish to create image extensions for your account, you may reach out to the Google Ads Product Support team instead, via this link, to confirm whether this is already possible via the Google Ads UI.

I hope this helps.

Best regards,


Reminder: Share your feedback about the Google Ads (AdWords) API! Take the 2021 Google Ads API and AdWords API Annual Survey
 
Google Logo
Peter Laurence Napa Oliquino
Google Ads API Team
 


ref:_00D1U1174p._5004Q2QGllD:ref

Algirdas Jarockis

unread,
Dec 31, 2021, 5:05:21 AM12/31/21
to AdWords API and Google Ads API Forum
Hello there.
I have the same error. Here https://developers.google.com/google-ads/api/docs/extensions/extensions it is stated that feed items are deprecated but still can't use the new way to link assets. When it is planned to support Image type assets?

Google Ads API Forum Advisor

unread,
Jan 3, 2022, 12:23:08 AM1/3/22
to algirdas...@gmail.com, adwor...@googlegroups.com

Hello Algirdas,

Thank you for reaching out to us.

As mentioned by my colleague (Peter) on the previous thread, currently supported asset based extensions are listed here and other types would follow later. In the meantime, we recommend that you keep an eye to our blog for future updates or any announcements on when image extensions can be included.

Regards,

Google Logo
Mark Kevin Albios
Google Ads API Team
 


ref:_00D1U1174p._5004Q2QGllD:ref
Reply all
Reply to author
Forward
0 new messages