Display locations for video ads

40 views
Skip to first unread message

Martin Vinter

unread,
Jul 15, 2025, 1:10:33 PMJul 15
to Google Ads Scripts Forum
Hi, 

I with to extract the locations where my video ads have been shown. The end-goal is to match them with rules and ad some of them to an exclusion list, but I haven't gotten that far yet.

I have tried a number of things, none of them successful. My latest attempt looks as bellow, but I have also tried with the SQL-like method of doing queries. How can I get placements for video campaigns?

Latest attempt of mine: 

function main() {
  var videoCampaignIterator = AdsApp.videoCampaigns().get();

  if (!videoCampaignIterator.hasNext()) {
    Logger.log("No video campaigns found.");
    return;
  }

  var allPlacements = [];

  while (videoCampaignIterator.hasNext()) {
    var videoCampaign = videoCampaignIterator.next();

    // Commented out campaign logging
    // Logger.log("Video Campaign Name: " + videoCampaign.getName());
    // Logger.log("Campaign ID: " + videoCampaign.getId());
    // Logger.log("Status: " + videoCampaign.getStatus());
    // Logger.log("Budget: " + videoCampaign.getBudget().getAmount());
    // Logger.log("-----------------------------");

    var placementIterator = videoCampaign.videoTargeting().placements().get();

    while (placementIterator.hasNext()) {
      var placement = placementIterator.next();
      allPlacements.push({
        resourceName: placement.getResourceName(),

      });
    }
  }

  // Log the collected placements
  for (var i = 0; i < allPlacements.length; i++) {
    Logger.log("Placement " + (i + 1) + ":");
    Logger.log("  Resource Name: " + allPlacements[i].resourceName);

  }

 
}

Google Ads Scripts Forum Advisor

unread,
Jul 15, 2025, 4:50:44 PMJul 15
to adwords...@googlegroups.com
Hi,

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

I would like to inform you that in order to fetch the location for the video ads, I would suggest you to refer to the available method 'targetedLocations()' under the 'AdsApp.​VideoCampaignTargeting'. In order to do any video placement or exclude video placement you can refer to the 'AdsApp.​VideoPlacementBuilder'. For more information related to video campaigns you can go through the Google Ads Scripts documentation related to video campaigns.

If you would like to fetch the placement view using an GAQL query, you can use the reporting option that is available in Google Ads Scripts. You can refer to the below sample example and can go through the detail_placement_view_query_builder to add additional fields from the resource based on your requirement.
 
function main(){

let report = AdsApp.report(
    "SELECT detail_placement_view.placement, detail_placement_view.placement_type, detail_placement_view.resource_name, detail_placement_view.target_url FROM detail_placement_view WHERE campaign.advertising_channel_type = 'VIDEO'");

let rows = report.rows();
while (rows.hasNext()) {
    let row = rows.next();
  console.log(row);
}
}
Feel free to get back in case of any further issues once the script is created by providing us with the below.
  • Google Ads Account ID/CID
  • Script Name
You can share the requested details via Reply privately to the author option or a direct private reply to this email.

Thanks,
 
Google Logo Google Ads Scripts Team

Feedback
How was our support today?

rating1    rating2    rating3    rating4    rating5
[2025-07-15 20:49:57Z GMT] This message is in relation to case "ref:!00D1U01174p.!500Ht01svkCa:ref" (ADR-00318997)



Martin Vinter

unread,
Jul 16, 2025, 3:01:49 AMJul 16
to Google Ads Scripts Forum
Hi!

It does just what it is supposed to. 

Thank you for your help!

Kind regards,
Martin
Reply all
Reply to author
Forward
0 new messages