Pmax targeting() function not working

46 views
Skip to first unread message

Boss Data

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

I am trying to select a PMAX campaign in my account and looking into the locations that are currently set as targeting location for that campaign.

In the documentation, I find that after selecting a PMAX campaign using the following code:

var campaignName = '123';
 
  // Retrieve the campaign
  const campaignIterator = AdsApp.performanceMaxCampaigns()
    .withCondition(`campaign.name = "${campaignName}"`)
    .get();
   
  if (campaignIterator.hasNext()) {
    var campaign = campaignIterator.next();

I can get the targeting like this:

campaign.targeting().targetedLocation()

This is mentioned as a possible function in the documentation here:
https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_performancemaxcampaign

However, this returns the following error:
TypeError: campaign.targeting is not a function at main (PMAXTEST:23:12) at Object.<anonymous> (adsapp_compiled:20520:54
Why doesn' this work, and how can I fix this?

Kind regards,

M

Google Ads Scripts Forum

unread,
Jun 28, 2024, 8:42:17 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.

It is not possible to get the targeting information of Performance Max Campaigns via its selector. Our documentation may be used as reference for the available methods that could be done with said campaign using it's selector. What could be done instead to retrieve targeting information on its ad schedules is by reporting, wherein a campaign_criterion report could be created filtered on campaign.advertising_channel_type of PERFORMANCE_MAX. I would recommend you follow the blog post for further updates on this feature.

I hope this helps! Feel free to contact us if you still have any concerns.

Thanks,
Google Ads scripts team

Reply all
Reply to author
Forward
0 new messages