How to use the google-ads-api.enums.AdGroupAdStatus function in google-ads-api

To help you get started, we’ve selected a few google-ads-api examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Opteo / google-ads-api / examples / basic_operations / add_expanded_text_ad.js View on Github external
async function main() {
    const customer = client.Customer({
        customer_account_id: '',
        refresh_token: '',
    })

    // Bonus: If you're using Typescript, set the type here to "types.AdGroupAd" for autocomplete
    const ad = {
        ad_group: 'customers/{customer_id}/adGroups/{ad_group_id}',
        status: enums.AdGroupAdStatus.PAUSED,
        ad: {
            final_urls: ['http://www.mywebsite.com'],
            expanded_text_ad: {
                headline_part_1: 'headline part one',
                headline_part_2: 'headline part two',
                description: 'ad description',
            },
        },
    }

    try {
        const { results } = await customer.adGroupAds.create(ad)
        /*
            The newly created ad will have a resource name in the following format:
            "customers/{customer_id}/adGroups/{ad_group_id}~{ad_id}"
        */
github Opteo / google-ads-api / examples / reporting / get_ads_performance.js View on Github external
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)
    }