I am trying to create a structure snippet here client is the instance of
GoogleAdsClient. Can you help me with updated code?
def create_snippet_asset(client, camp_data):
try:
# Define the constants
CUSTOMER_ID = str(camp_data["customer_id"])
AD_GROUP_ID = str(camp_data["ad_group_id"])
# Get the AdGroupExtensionSettingService
ad_group_extension_setting_service = client.get_service(
"AdGroupExtensionSettingService")
# Create a structure snippet extension
structure_snippet_extension = client.get_type(
"StructuredSnippetFeedItem")
structure_snippet_extension.header = "Brands"
# string_value = client.get_type("StringValue", version="v14")
structure_snippet_extension.values.extend([
"Nike",
"Adidas",
"Reebok"
])
# Create an ad group extension setting operation
ad_group_extension_setting_operation = client.get_type(
"AdGroupExtensionSettingOperation")
ad_group_extension_setting =
ad_group_extension_setting_operation.create
ad_group_extension_setting.ad_group =
ad_group_extension_setting_service.ad_group_path(
CUSTOMER_ID, AD_GROUP_ID
)
ad_group_extension_setting.extension_type = client
.enums.ExtensionTypeEnum.STRUCTURED_SNIPPET
ad_group_extension_setting.extension_feed_items.append(structure_snippet_extension)
# Add the ad group extension setting
response =
ad_group_extension_setting_service.mutate_ad_group_extension_settings(
customer_id=CUSTOMER_ID, operations=
[ad_group_extension_setting_operation]
)
# Print the result
print(f"Created a structure snippet extension with resource name: {
response.results[0].resource_name}")
except Exception as e:
print(f'Error occured while creating structure snippet {e}')
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
---
You received this message because you are subscribed to the Google Groups
"Google Ads API and AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/adwords-api/b0b3209b-db87-4245-ab21-7db26527cb53n%40googlegroups.com.