How to add Adding Sitelinks to Campaign in Google Ads

80 views
Skip to first unread message

F B

unread,
Mar 21, 2019, 6:41:15 AM3/21/19
to AdWords API and Google Ads API Forum
Hi there,

I am using the Python client library and was able to start adding campaigns to an account. However I am currently struggling with adding SiteLinks and other extensions.

I feel like one should create a Feed with Feeditems and add them to the campaign, but I am unsure how to exactly do this with the python library. Any pointers would be appreciated.

googleadsapi...@google.com

unread,
Mar 21, 2019, 2:03:21 PM3/21/19
to AdWords API and Google Ads API Forum
Hello, 

If you're using the Google Ads API, you may use the CampaignFeedService and AdGroupFeedService and use the PlaceholderType to create the Sitelink feeds. Currently we do not have a Python code sample to create the Sitelink extensions. We have raised this as a feature request to the team. To get you started, please find the attached code sample in Java assuming that the feed already exists to associate the Sitelink feeds to campaign or adgroup.

Could you please give this a try with the shared sample and let me know if you have any other questions?

Regards,
Bharani, Google Ads API Team

=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
    http://googleadsdeveloper.blogspot.com/search/label/adwords_api
    https://developers.google.com/adwords/api/community/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

Was your question answered? Please rate your experience with us by taking a short survey.
If not -- reply to this email and tell us what else we can do to help.

Take Survey

Also find us on our blog and discussion group:
http://googleadsdeveloper.blogspot.com/search/label/adwords_api
https://developers.google.com/adwords/api/community/

Sample_Logs.rtf

F B

unread,
Mar 21, 2019, 2:45:06 PM3/21/19
to AdWords API and Google Ads API Forum
feed_service = client.get_service('ExtensionFeedItemService', version='v1')

extension_feed_item_operation = client.get_type('ExtensionFeedItemOperation', version='v1')
extension_feed_item = extension_feed_item_operation.create
extension_feed_item.sitelink_feed_item.link_text.value = 'Text'
extension_feed_item.sitelink_feed_item.line1.value = 'Line 1 Value'
extension_feed_item.sitelink_feed_item.line2.value = 'Line 2 Value'
final_url = extension_feed_item.sitelink_feed_item.final_urls.add()
final_url.value = 'www.example.com'

# Add extension
try:
    feed_response = (
        feed_service.mutate_extension_feed_items(customer_id, [extension_feed_item_operation])
    )
except google.ads.google_ads.errors.GoogleAdsException as ex:
    print('Request with ID "%s" failed with status "%s" and includes the '
          'following errors:' % (ex.request_id, ex.error.code().name))
    for error in ex.failure.errors:
        print('\tError with message "%s".' % error.message)
        if error.location:
            for field_path_element in error.location.field_path_elements:
                print('\t\tOn field: %s' % field_path_element.field_name)
    sys.exit(1)


print('Created Sitelink %s.' % feed_response.results[0].resource_name).


This actually works. But its so hard to get Ids ...

googleadsapi...@google.com

unread,
Mar 21, 2019, 5:21:29 PM3/21/19
to AdWords API and Google Ads API Forum
Hello, 

You will be able to use the FeedFeed ItemExtension Feed Item resources to pull the Feed Ids. You may also use the Interactive Query Builder to build the query. 

Thanks,
Bharani, Google Ads API Team

=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
    http://googleadsdeveloper.blogspot.com/search/label/adwords_api
    https://developers.google.com/adwords/api/community/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

Was your question answered? Please rate your experience with us by taking a short survey.
If not -- reply to this email and tell us what else we can do to help.

Take Survey

Also find us on our blog and discussion group:
http://googleadsdeveloper.blogspot.com/search/label/adwords_api
https://developers.google.com/adwords/api/community/

--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 adwor...@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscribe@googlegroups.com
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 "AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adwords-api+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/adwords-api.
To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-api/e980c441-7f54-4c2f-a6ed-c3a0f245670c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Message has been deleted

F B

unread,
Mar 22, 2019, 9:01:51 AM3/22/19
to AdWords API and Google Ads API Forum
Hi there,

thx for the pointer towards the Feed and Feed Item ressources, I as looking at the Extension Feed Items before (with the Interactive Query Builder) but I couln't quite figure out how to link them to Feed or Feed Item for that matter and thus get an Id.

Because unfortunately the Extension Feed Item does not have an id.

Cheers
Fabian

googleadsapi...@google.com

unread,
Mar 22, 2019, 1:41:21 PM3/22/19
to AdWords API and Google Ads API Forum
Hello,

@Vito: We have already raised a feature request for the code samples in PHP. Please keep an eye on our blog for more updates.

@Fabian: We will let the team know of your pull request. You could use the specific campaign_feed and ad_group_feed which will return the corresponding Feed resource associated with the campaign from which you can get the Feed Id. Please find below the sample query:

SELECT campaign_feed.feed, campaign_feed.campaign from campaign_feed

Let me know if you have any other questions.

Regards,
Bharani, Google Ads API Team

=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
    http://googleadsdeveloper.blogspot.com/search/label/adwords_api
    https://developers.google.com/adwords/api/community/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Reply all
Reply to author
Forward
0 new messages