The code from the example doesn't work

57 views
Skip to first unread message

Igor Sayutin

unread,
Apr 1, 2024, 12:34:37 PMApr 1
to Google Ads Scripts Forum
I took the code from the example on this page and decided to run it
Campaigns  |  Google Ads Scripts  |  Google for Developers

function getAllCampaigns() {
 
// AdsApp.campaigns() will return all campaigns that are not removed by
 
// default.
 
const campaignIterator = AdsApp.campaigns().get();
  console
.log(`Total campaigns found : ${campaignIterator.totalNumEntities()}`);
 
return campaignIterator;
}

Response: Total campaigns found : 0
But despite the fact that I have many campaigns and have admin rights, this code shows that I have no campaigns.
What's wrong with that?

Nils Rooijmans

unread,
Jun 26, 2024, 2:48:06 AM (7 days ago) Jun 26
to Google Ads Scripts Forum
could it be you only have non-search and non-dispay campaigns in your account?
you are using a standard campaign selector, only search and display campaigns are supported in the standard campaign selector.
For other campaign types you should use the specific selectors (such as ShoppingCampaignSelector for shopping ,  VideoCampaignSelector for video campaigns, and PerformanceMaxCampaignSelector for Performance Max campaigns).

Google Ads Scripts Forum Advisor

unread,
Jun 26, 2024, 5:53:06 AM (7 days ago) Jun 26
to adwords...@googlegroups.com

Hi,

@Nils Thanks for providing the detailed solution.

I would suggest that you refer to the solution provided by Nils. Kindly get back to us with the below details if the issue still persists.

  • Google Ads account ID/CID
  • Name of the affected script
  • Shareable spreadsheet link if you are using in your script
You can share the requested details via Reply privately to the author option or a direct private reply to this email. 

This message is in relation to case "ref:!00D1U01174p.!5004Q02tJTXw:ref" (ADR-00243908)

Thanks,
 
Google Logo Google Ads Scripts Team


Reply all
Reply to author
Forward
0 new messages