Is it Possible to Remove Sitelinks From an Account Using Ads Scripts?

41 views
Skip to first unread message

Finn Harnett O'Meara

unread,
Feb 8, 2019, 7:01:26 AM2/8/19
to Google Ads Scripts Forum
Hi,

Is it possible to remove campaign level sitelinks using Google Scripts? I know you can use .removeSitelink() on a campaign or by using .setEndDate() but is it possible to actually delete them from the account?

Also can you use .removeSitelink() to remove all sitelinks associated with a particular campaign without specifying the sitelink id?

Also what is the best way of removing sitelinks that have no associations?

Thank you

Finn Harnett O'Meara

unread,
Feb 8, 2019, 8:30:51 AM2/8/19
to Google Ads Scripts Forum


On Friday, 8 February 2019 12:01:26 UTC, Finn Harnett O'Meara wrote:
Hi,

Is it possible to remove campaign level sitelinks using Google Scripts? I know you can use .removeSitelink() on a campaign or by using .setEndDate() but is it possible to actually delete them from the account?

Also what is the best way of removing sitelinks that have no associations?

Thank you

Ignore the second point, I misunderstood the documentation 

googleadsscrip...@google.com

unread,
Feb 8, 2019, 3:20:17 PM2/8/19
to Finn Harnett O'Meara via Google Ads Scripts Forum, Google Ads Scripts Forum
Hello,

Removing a sitelink from an account, campaign or ad group is effectively deleting the sitelink from the account. You can remove all sitelinks from a campaign with the following code without referencing the sitelink ID:

function main() {
  
  
var campaign = AdsApp.campaigns().withCondition("Name = 'CAMPAIGN_NAME'").get().next();   
  
var sitelinks = campaign.extensions().sitelinks().get();
  
  
while(sitelinks.hasNext()) {
  
    
var sitelink = sitelinks.next();
    campaign
.removeSitelink(sitelink);
    
  
}  
}

Please let us know if you have any other questions.

Regards,
Matt
Google Ads Scripts Team
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
    http://googleadsdeveloper.blogspot.com/search/label/adwords_scripts
    https://developers.google.com/google-ads/scripts/community/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

--
-- You received this message because you are subscribed to the Google Groups AdWords Scripts Forum group. Please do not reply to this email. To post to this group or unsubscribe please visit https://developers.google.com/adwords/scripts/community.
---
You received this message because you are subscribed to the Google Groups "Google Ads Scripts Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adwords-scripts+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-scripts/e9cb2bd1-6013-4916-8015-a45e0e0c66a8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Finn Harnett O'Meara

unread,
Feb 11, 2019, 9:17:29 AM2/11/19
to Google Ads Scripts Forum
Hi, 

Thanks for the response. Is there a way to actually delete the sitelink entity. If I remove sitelinks from a campaign the actual sitelink entity will still exist in the account right? Is there a way to remove it with a script? I know it is possible through the interface.

Thank you,

Finn


On Friday, 8 February 2019 20:20:17 UTC, googleadsscripts-forumadvisor wrote:
Hello,

Removing a sitelink from an account, campaign or ad group is effectively deleting the sitelink from the account. You can remove all sitelinks from a campaign with the following code without referencing the sitelink ID:

function main() {
  
  
var campaign = AdsApp.campaigns().withCondition("Name = 'CAMPAIGN_NAME'").get().next();   
  
var sitelinks = campaign.extensions().sitelinks().get();
  
  
while(sitelinks.hasNext()) {
  
    
var sitelink = sitelinks.next();
    campaign
.removeSitelink(sitelink);
    
  
}  
}

Please let us know if you have any other questions.

Regards,
Matt
Google Ads Scripts Team
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
    http://googleadsdeveloper.blogspot.com/search/label/adwords_scripts
    https://developers.google.com/google-ads/scripts/community/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

googleadsscrip...@google.com

unread,
Feb 11, 2019, 1:52:33 PM2/11/19
to Finn Harnett O'Meara via Google Ads Scripts Forum, Google Ads Scripts Forum
Hi Finn,

At the moment, it is only possible to remove sitelink extensions through Scripts. If we make any relevant changes, we will post about it on our blog.

If you have any questions about removing or deleting sitelinks in the UI, please reach out to product support here.

Regards,
Matt
Google Ads Scripts Team
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
    http://googleadsdeveloper.blogspot.com/search/label/adwords_scripts
    https://developers.google.com/google-ads/scripts/community/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

Reply all
Reply to author
Forward
0 new messages