Airflow Summit 2025 is coming October 07-09. Register now for early bird ticket!

tests.system.google.ads.example_ads

Example Airflow DAG that shows how to use GoogleAdsToGcsOperator.

In order to run this test, make sure you followed steps: 1. In your GCP project create a service account that will be used to operate on Google Ads. The name should be in format google-ads-service-account@{PROJECT_ID}.iam.gserviceaccount.com 2. Generate a key for this service account and store it in the Secret Manager under the name google_ads_service_account_key. 3. Give this service account Editor permissions. 4. Make sure Google Ads API is enabled in your GCP project. 5. Login to https://ads.google.com 6. In the Admin section go to Access and Security and give your GCP service account Admin permissions. 7. Store values of your developer token and client ID to Secret Manager under names google_ads_client_id and google_ads_developer_token.

Attributes

ENV_ID

PROJECT_ID

API_VERSION

DAG_ID

GOOGLE_ADS_CLIENT_ID

GOOGLE_ADS_SERVICE_ACCOUNT_KEY

GOOGLE_ADS_DEVELOPER_TOKEN

BUCKET_NAME

GCS_OBJ_PATH

GCS_ACCOUNTS_CSV

QUERY

CONNECTION_GLOUD_ID

CONNECTION_ADS_ID

CONNECTION_TYPE

FIELDS_TO_EXTRACT

log

test_run

Functions

get_secret(secret_id)

get_google_ads_client_id()

Module Contents

tests.system.google.ads.example_ads.ENV_ID[source]
tests.system.google.ads.example_ads.PROJECT_ID[source]
tests.system.google.ads.example_ads.API_VERSION = 'v20'[source]
tests.system.google.ads.example_ads.DAG_ID = 'google_ads'[source]
tests.system.google.ads.example_ads.GOOGLE_ADS_CLIENT_ID = 'google_ads_client_id'[source]
tests.system.google.ads.example_ads.GOOGLE_ADS_SERVICE_ACCOUNT_KEY = 'google_ads_service_account_key'[source]
tests.system.google.ads.example_ads.GOOGLE_ADS_DEVELOPER_TOKEN = 'google_ads_developer_token'[source]
tests.system.google.ads.example_ads.BUCKET_NAME = 'bucket_ads_Uninferable'[source]
tests.system.google.ads.example_ads.GCS_OBJ_PATH = 'gs://bucket_ads_Uninferable/google-ads-api-results.csv'[source]
tests.system.google.ads.example_ads.GCS_ACCOUNTS_CSV = 'accounts.csv'[source]
tests.system.google.ads.example_ads.QUERY = Multiline-String[source]
Show Value
"""
    SELECT
        segments.date,
        customer.id,
        campaign.id,
        ad_group.id,
        ad_group_ad.ad.id,
        metrics.impressions,
        metrics.clicks,
        metrics.conversions,
        metrics.all_conversions,
        metrics.cost_micros
    FROM
        ad_group_ad
    WHERE
        segments.date >= '2020-02-01'
        AND segments.date <= '2020-02-29'
    """
tests.system.google.ads.example_ads.CONNECTION_GLOUD_ID = 'connection_cloud_google_ads_Uninferable'[source]
tests.system.google.ads.example_ads.CONNECTION_ADS_ID = 'google_ads_default'[source]
tests.system.google.ads.example_ads.CONNECTION_TYPE = 'google_cloud_platform'[source]
tests.system.google.ads.example_ads.FIELDS_TO_EXTRACT = ['segments.date.value', 'customer.id.value', 'campaign.id.value', 'ad_group.id.value',...[source]
tests.system.google.ads.example_ads.log[source]
tests.system.google.ads.example_ads.get_secret(secret_id)[source]
tests.system.google.ads.example_ads.get_google_ads_client_id()[source]
tests.system.google.ads.example_ads.test_run[source]

Was this entry helpful?