PMAX campaign - targeting function not working

50 views
Skip to first unread message

Boss Data

unread,
Jun 25, 2024, 12:04:34 PM (8 days ago) Jun 25
to Google Ads Scripts Forum
Dear support,

I am trying to run following script, which is using the latest documentation on PMAX campaigns:

var campaignName = 'example';
 
  // Retrieve the search campaign
  var campaignIterator = AdsApp.performanceMaxCampaigns()
    .withCondition(`campaign.name = "${campaignName}"`)
   .get();


  if (campaignIterator.hasNext()) {
    var campaign = campaignIterator.next();
    Logger.log('Campaign found: ' + campaign.getName());
 
  }
 
  var locationIterator = campaign.targeting().targetedLocations().get()
 
   while (locationIterator.hasNext()) {
      var location = locationIterator.next();
      Logger.log('Location ID: ' + location.getId());
      Logger.log('Location Name: ' + location.getName());
      Logger.log('Bid Modifier: ' + location.getBidModifier());
    }


But the "targeting()" function is giving following error on the successfully selected PMAX campaign:

TypeError: campaign.targeting is not a function at main (PMAXTEST:17:35) at Object.<anonymous> (adsapp_compiled:20520:54) Why is this not working? According to the documentation, it should. 

Kind regards,

M

Google Ads Scripts Forum

unread,
Jun 28, 2024, 8:43:12 AM (5 days ago) Jun 28
to Google Ads Scripts Forum

Hi M,

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

I see that you have already raised this concern on another thread with the subject "Pmax targeting() function not working" and we have already responded there for this issue. To avoid multiple threads on the same issue, please take a look at that thread and continue the discussion on the same for further updates on the issue.

Thanks,
Google Ads scripts team
Reply all
Reply to author
Forward
0 new messages