Change ROAS of PMax Campaign selected via label

110 views
Skip to first unread message

Dominik Fischer

unread,
Mar 27, 2024, 7:21:39 PM3/27/24
to Google Ads Scripts Forum
Hi,

I am working on a solution to change tROAS for several PMax campaigns depending on the current weather on the weekend.

I decides to set up 2 scripts:

1) Fetch weather data, lower tROAS of PMax campaigns & set a label when done -> script is working (runs on Friday)

2) Select PMax Campaigns with the added label and increase ROAS (runs on Sunday)
I can´t get this script to work.

Currently I am sitting on something like this

function main() {

    var campaignName = '(01) PMax | Inventory all | Productgroup Aggressive | CSS: Google';
    var bidAdjustment = 50;
    var namelabel = 'Weather';
 
 
var label = AdsApp.labels().withCondition("LabelNames CONTAINS 'Weather'").get().next();
var Campaigns = label.Campaigns();


while (Campaigns.hasNext()) {
  var Campaigns = Campaigns.next();
        Logger.log("Setting new tROAS because ROAS was reduced during Weekend");
        setCampaignTRoas(campaignName, bidAdjustment);
    }
 
 
}

function setCampaignTRoas(name, bidAdjustment) {
    var campaignIterator = AdsApp.performanceMaxCampaigns()
                                                    .withCondition('label.name = "Weather"')
                                                    .get();

    while(campaignIterator.hasNext()) {
        var campaign = campaignIterator.next();
        const currentTRoas = campaign.bidding().getTargetRoas();
        var newTRoas = currentTRoas + bidAdjustment;
        campaign.bidding().setTargetRoas(newTRoas);
        campaign.removeLabel(namelabel);
             
    }
}

Best regards

Nils Rooijmans

unread,
Sep 19, 2024, 3:17:08 AM9/19/24
to Google Ads Scripts Forum
the problem is caused by the fact that PMax campaigns require a different kind of iterator; 

Unfortunately, only search and display campaigns are supported in the standard campaign selector.
Google Ads Scripts provides separate methods and classes for accessing Performance Max campaign data.

Here’s how to define Selectors and Iterators for Performance Max campaigns using the latest version:
https://nilsrooijmans.com/google-ads-scripts-faq/google-ads-scripts-201-how-to-create-selectors-and-iterators-for-performance-max/

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/

Google Ads Scripts Forum Advisor

unread,
Sep 19, 2024, 9:06:43 AM9/19/24
to adwords...@googlegroups.com
Hi,

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

@ Nils - Thank you for your input.

You may follow Nil's suggestion. Let me know how it goes on your end and If you face any issue, provide us with the following details to replicate the issue from our side: 

  • Google Ads account ID / CID
  • Name of the script
  • Error details or screenshot of the issue (if any)

You can send the details via Reply privately to the author option, or direct private reply to this email.

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

Thanks,
 
Google Logo Google Ads Scripts Team


Reply all
Reply to author
Forward
0 new messages