Bug in .setTargetRoas()

38 views
Skip to first unread message

Salvatore Aranzulla

unread,
Jul 18, 2024, 11:37:38 AM (9 days ago) Jul 18
to Google Ads Scripts Forum
The script for setting the target ROAS works perfectly but enters an infinite loop when dealing with a mix of standard and performance max (pmax) campaigns. The issue specifically occurs during the ROAS setting process. 

accountData[locale].forEach(function(accountInfo) {
            var account = AdsManagerApp.accounts().withIds([accountInfo.accountId]).get().next();
            AdsManagerApp.select(account);

            accountInfo.campaignIds.forEach(function(campaignId) {
                var campaign = AdsApp.performanceMaxCampaigns().withIds([campaignId]).get().hasNext()
                    ? AdsApp.performanceMaxCampaigns().withIds([campaignId]).get().next()
                    : AdsApp.campaigns().withIds([campaignId]).get().next();
            });
               campaign.bidding().setTargetRoas(troasAdjusted);
        });


I can share a video and the code privately.

Thanks,
Salvatore

Google Ads Scripts Forum Advisor

unread,
Jul 18, 2024, 12:29:21 PM (9 days ago) Jul 18
to adwords...@googlegroups.com

Hi,

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

I would suggest that you create a separate loop for PMax and standard campaign types. Also, to set a target roas bidding amount, use below methods.

Standard campaigns: AdsApp.CampaignBidding.setTargetRoas(targetRoas)  
PMax campaigns: AdsApp.PerformanceMaxCampaignBidding.setTargetRoas(targetRoas)

I would recommend that you refer to the AdsApp.​CampaignBidding and AdsApp.PerformanceMaxCampaignBidding documents for more information.

I hope this helps! Kindly get back to us if the issue still persists. 

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

Thanks,
 
Google Logo Google Ads Scripts Team


Salvatore Aranzulla

unread,
Jul 18, 2024, 2:51:21 PM (9 days ago) Jul 18
to Google Ads Scripts Forum

I tried implementing a separate loop, but the bug still seems to be present. The bug causes the target to be changed in some accounts, but not in all. Therefore, not in all campaigns.

  1. I am sharing the code below:

    https://pastebin.com/GGm7rPrV

  2. In the following image, you can see the infinite loop:





What do you suggest I do?

Thank you, Salvatore



Screenshot 2024-07-18 alle 20.24.23.png

Google Ads Scripts Forum Advisor

unread,
Jul 18, 2024, 3:23:58 PM (9 days ago) Jul 18
to adwords...@googlegroups.com

Hi,

In order to investigate the issue further, could you please provide us with the below details?

  • Google Ads account ID/CID
  • Name of the affected script
You can share the requested details via Reply privately to the author option or a direct private reply to this email. If this option is not available on your end, you may send it through our email (googleadsscr...@google.com) instead.

Christopher Simmons

unread,
Jul 19, 2024, 6:16:00 AM (8 days ago) Jul 19
to Google Ads Scripts Forum on behalf of adsscripts
Hello, thanks for the information !

--
-- 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-scrip...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-scripts/ik_WT000000000000000000000000000000000000000000000SGTV4A008JHSBntaTaeEJ6MRLMrvbA%40sfdc.net.
Reply all
Reply to author
Forward
0 new messages