Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function main() {
const customer = client.Customer({
customer_account_id: '',
refresh_token: '',
})
try {
const results = await customer.report({
entity: 'ad_group',
attributes: ['campaign.id', 'ad_group.id', 'ad_group.name'],
constraints: [{ 'ad_group.status': enums.AdGroupStatus.ENABLED }],
})
for (const { campaign, ad_group } of results) {
console.log(`
Ad group with ID ${ad_group.id} and name "${ad_group.name}"
was found in campaign with ID ${campaign.id}
`)
}
} catch (err) {
console.log(err)
}
}
async function main() {
const customer = client.Customer({
customer_account_id: '',
refresh_token: '',
})
try {
const results = await customer.report({
entity: 'ad_group_ad',
attributes: ['ad_group.id', 'ad_group_ad.ad.id'],
metrics: ['metrics.clicks', 'metrics.impressions'],
segments: ['segments.date'],
constraints: [
{ 'ad_group.status': enums.AdGroupStatus.ENABLED },
{ 'ad_group_ad.status': enums.AdGroupAdStatus.ENABLED },
],
date_constant: 'LAST_7_DAYS',
order_by: 'metrics.clicks',
})
for (const { ad_group, ad_group_ad, metrics, segments } of results) {
const { ad } = ad_group_ad
console.log(
`Ad ID ${ad.id} in ad group ID ${ad_group.id} with ${metrics.impressions} impressions on day ${
segments.date
} had ${metrics.clicks} clicks during the last 7 days.`
)
}
} catch (err) {
console.log(err)