GAQL running on an MCC doesn't show a campaign
I've tried to run this GAQL on an MCC, but didn't get any rows.
ads-script:
campaignIds query =SELECT customer.id, campaign.resource_name, campaign.name FROM campaign WHERE campaign.id IN ("123456"); _rowsToMap(accountToCampaignsMap, AdsApp.report(query, REPORTING_OPTIONS)); } function _rowsToMap(map, response) { rows = response.rows(); while (rows.hasNext()) { var row = rows.next(); Logger.log(JSON.stringify(row)); ... }
Even though I see it in the UI under this MCC
What am I missing?
it's because you don't have campaigns on this account, but in managed accounts you do. Try first get list of managed accounts then query every one, lige this:
const query = 'selsct ... from ...' const accounts = AdsManagerApp.accounts().get() const campaignsData = [] while (accounts.hasNext()) { var account = accounts.next(); AdsManagerApp.select(account) const search = AdsApp.search(query) while (search.hasNext()) { const searchRow = search.next(); campaignsData.push({ accountName: account.getName(), accointId: account.getCustomerId(), ..., }) } }