Missing campaigns when iterating over AdsApp.shoppingCampaigns().get()

46 views
Skip to first unread message

Romeo Tiperciuc

unread,
Mar 13, 2020, 1:02:25 PM3/13/20
to Google Ads Scripts Forum
Hello, I'm trying to iterate over all the campaigns of an account and sum their costs for this month. I'm doing the following:

    var camp_rows = AdsApp.campaigns().get();
   
while(camp_rows.hasNext()) {
       
var c = camp_rows.next();
        cost
= c.getStatsFor('THIS_MONTH').getCost();
       
Logger.log("Campaign " + c.getName() + " cost: " + cost);
        tot_cost
+= cost;
   
}

However what I found strange is that a specific campaign of type shopping is not included in the returned results. After looking over the AdsApp API I noticed the shoppingCampaings() method so I thought that might be it. So I gave a try by adding the following code:

    var shopping_camp_rows = AdsApp.shoppingCampaigns().get();
   
while(shopping_camp_rows.hasNext()) {
       
var c = camp_rows.next();
        cost
= c.getStatsFor(TIMEFRAME).getCost();
       
Logger.log("Shopping campaign " + c.getName() + " cost: " + cost);
        tot_cost
+= cost;
   
}

I'm getting 0 entries back, even though I have a campaign with type shopping registered.

What's going on ? Am I doing something wrong ? Am I understanding something wrong ?

Sigurd

unread,
Mar 13, 2020, 2:08:51 PM3/13/20
to Google Ads Scripts Forum
Guess it's a smart shopping campaign you are missing data for. They are not accessible from scripts.

When it's only stats you're after, try using api reports instead. You'll get all data that way - and it's faster.
AdsApp.report('SELECT Cost ..')



  sigurd

Google Ads Scripts Forum Advisor

unread,
Mar 13, 2020, 3:26:33 PM3/13/20
to adwords-scripts+apn2wqevinbbivog...@googlegroups.com, adwords...@googlegroups.com
Hi Romeo,

As Sigurd suggested, smart campaigns are not supported in scripts at the moment. 

However, support for this campaign type has been requested in the past, and if we make any relevant changes, we will post about it on the blog.

Regards,
Matt
Google Ads Scripts Team

ref:_00D1U1174p._5001UXV1ZS:ref
Reply all
Reply to author
Forward
0 new messages