function main() { // Campaign Selection var campaignName = "Campaign Name"; // Ad Rotation Strategy (Choose one and adjust) var rotationStrategy = { // 1. Rotate Evenly: Give all ads equal chance // "ROTATE_EVENLY" // 2. Optimize for Clicks: Show higher-performing ads more often // "OPTIMIZE_FOR_CLICKS" // 3. Optimize for Conversions: Prioritize ads driving conversions // "OPTIMIZE_FOR_CONVERSIONS" // 4. Rotate Indefinitely: Don't automatically select an ad "ROTATE_INDEFINITELY" } // Get the specified campaign var campaign = AdsApp.campaigns().withCondition("Name = '" + campaignName + "'").get().next(); // Set the ad rotation type var adRotationType = campaign.getAdRotationType(); // Apply only if rotation settings need to be changed if (adRotationType != rotationStrategy) { campaign.setAdRotationType(rotationStrategy); } }