AdWords
2.3K members online now
2.3K members online now
Dive into advanced features like Remarketing, Flexible Bid Strategies, AdWords Editor, and AdWords Scripts
Guide Me
star_border
Reply

Issue with sitelinkIterator

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hi there,

 

I am trying to write a script that returns the number of sitelinks per campaign in order to identify campaigns missing sitelinks. I've created a sitelinkIterator, as per Google's documentation, but whenever I run the script it returns a value of 0 (sitelinks) for each campaign.

 

Is there an issue with the code below? Or has someone experienced the same issue when using totalNumEntities? Any help would be much appreciated. 

 

var campaignIterator = AdWordsApp.campaigns().get();
 
  while (campaignIterator.hasNext()) {
     var campaign = campaignIterator.next();
     var campaignName = campaign.getName();
     var campaignSitelinks = campaign.extensions().sitelinks().get().totalNumEntities();
     Logger.log(campaignName + " " + campaignSitelinks);
}

Re: Issue with sitelinkIterator

Participant ✭ ✭ ✭
# 2
Participant ✭ ✭ ✭
Hi Lars,

Not sure what the issue is.

I copy pasted your script into a function and it worked 100% on my side.

Is it possible that your campaigns have 0 sitelinks (they could be set at the account or ad group level or not at all)?

Re: Issue with sitelinkIterator

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭
Hi Clynton,

Our sitelinks are in the shared library and associated from there to individual campaigns. The individual sitelinks have data at the campaign level which is why I don't understand why the script isn't working.

Thanks for trying the script on your end.

Re: Issue with sitelinkIterator

Participant ✭ ✭ ✭
# 4
Participant ✭ ✭ ✭
Hi Lars,

That is very weird then, as that is my exact set up (although some sitelinks are at an adgroup level as well) and the script above works for me.