We have scripts on our GoogleAds account that periodically extract campaign report data from the platform and saves them in our BigQuery database on Google Cloud.
The script begins by looping over all our accounts and then fetches the reports of the campaigns under each account:
var excluded_account_ids = ['xxx', 'xxx', 'xxx'];
// Retrieve all child accounts.
var accountIterator = AdsManagerApp.accounts().get();
// this array will hold all of the insert
var values_array = [];
// Iterate through the account list.
while (accountIterator.hasNext()) {
var account = accountIterator.next();
// Making sure that the account ID isn't among the excluded ones
if(excluded_account_ids.indexOf(account.getCustomerId()) < 0) {
Logger.log(account.getCustomerId())
AdsManagerApp.select(account);
var report = AdsApp.report(
'SELECT Date, CampaignId, CampaignName, AdGroupId, AdGroupName, Device, DayOfWeek, Impressions, Clicks, Ctr, VideoViews, VideoViewRate, VideoQuartile100Rate, VideoQuartile25Rate, VideoQuartile50Rate, VideoQuartile75Rate, Conversions, Cost, ActiveViewMeasurability, ActiveViewViewability, ActiveViewImpressions, ActiveViewMeasurableImpressions, ViewThroughConversions ' +
'FROM ADGROUP_PERFORMANCE_REPORT ' +
'DURING ' + current_date[0] + ',' + current_date[0], {
includeZeroImpressions: false,
returnMoneyInMicros: true
});
var rows = report.rows();
When we print the customer IDs fetched by the above script, we get 207 different customer IDs.
However, when we try to do the same in our python scripts through APIs, we're only able to get the IDs of the most top-level accounts (only 3 IDs and one isn't enabled) and when we proceed with fetching the campaigns under these top-level accounts, the search always comes back empty. A snippet of the python script is attached and our main account's customer ID is 325-177-1939.