AdsApp.campaigns() doesn't get campaigns

106 views
Skip to first unread message

Endri Bulku

unread,
Sep 21, 2023, 6:14:02 AM9/21/23
to Google Ads Scripts Forum
I am trying to build the script and right now I am stuck at just logging the information of my campaigns, it shows 0.

My account id is: 432-320-0125


Screenshot 2023-09-10 153439.png

Nils Rooijmans

unread,
Sep 22, 2023, 2:17:51 AM9/22/23
to Google Ads Scripts Forum
most probably the account you are running the script in doesn't have any standard search or display campaigns?

If you want to see your shopping or pmax campaigns you need to create selectors for these campaign types, see:  

Hope this helps,

Nils Rooijmans
https://nilsrooijmans.com
See my Google Ads Scripts FAQ to avoid the same mistakes I made: https://nilsrooijmans.com/google-ads-scripts-faq/


Endri Bulku

unread,
Sep 25, 2023, 5:06:53 AM9/25/23
to Google Ads Scripts Forum
I found the issue and the solution. I had to iterate through the sub accounts, the campaigns were not directly to my main account:

function main() {
    var accountSelector = AdsManagerApp.accounts();
    var accountIterator = accountSelector.get();
    while (accountIterator.hasNext()) {
      var account = accountIterator.next();
      var accountname = account.getName();
      console.log({accountname});
      AdsManagerApp.select(account);
      var campaignIterator = AdsApp.campaigns().get();
      console.log('Total campaigns:' + campaignIterator.totalNumEntities());
      while (campaignIterator.hasNext()) {
        var campaign = campaignIterator.next();
        console.log(`${campaign.getName()}; active? ${campaign.isEnabled()}; budget=${campaign.getBudget().getAmount()}`);
      }
      console.log('Finished listing campaigns.');

Google Ads Scripts Forum Advisor

unread,
Sep 26, 2023, 11:00:10 AM9/26/23
to adwords...@googlegroups.com
Hi,

Thank you for reaching out to the Google Ads Scripts support team.

The solution provided by Endri Bulku is correct. Please let us know if you run into any issues with this solution.

Please reach out to us if you have any queries related to the Google Ads Scripts.
 
This message is in relation to case "ref:_00D1U1174p._5004Q2p12uG:ref"

Thanks,
 
Google Logo Google Ads Scripts Team

 

Reply all
Reply to author
Forward
0 new messages