Platforms

  • The provided content contains a Google Ads script function to set a mobile bid modifier for a specified campaign.

  • The function takes the campaign name and an optional bid modifier value as input.

  • It retrieves the specified campaign, and if found, sets the bid modifier for the mobile platform target within that campaign.

  • An error is thrown if the campaign with the given name is not found.

Set mobile bid modifier for a campaign

function setMobileBidModifier(campaignName, bidModifier = 1.5) {
  const campaignIterator = AdsApp.campaigns()
      .withCondition(`campaign.name = "${campaignName}"`)
      .get();
  if (!campaignIterator.hasNext()) {
    throw new Error(`No campaign with name "${campaignName}" found`);
  }

  const campaign = campaignIterator.next();
  // Retrieve the mobile target for campaign.
  const mobileTargetIterator = campaign.targeting().platforms().mobile().get();
  if (mobileTargetIterator.hasNext()) {
    mobileTarget = mobileTargetIterator.next();
    // Set the bid modifier for mobile platform.
    mobileTarget.setBidModifier(bidModifier);
  }
}