Google Search Ads Operators

Create, manage, and track high-impact campaigns across multiple search engines with one centralized tool. For more information check Google Search Ads.

Inserting a report

To insert a Search Ads report use the GoogleSearchAdsInsertReportOperator.

airflow/providers/google/marketing_platform/example_dags/example_search_ads.pyView Source

generate_report = GoogleSearchAdsInsertReportOperator(report=REPORT, task_id="generate_report")

You can use Jinja templating with report, impersonation_chain parameters which allows you to dynamically determine values. You can provide report definition using `` .json`` file as this operator supports this template extension. The result is saved to XCom, which allows it to be used by other operators:

airflow/providers/google/marketing_platform/example_dags/example_search_ads.pyView Source

report_id = "{{ task_instance.xcom_pull('generate_report', key='report_id') }}"

Awaiting for a report

To wait for a report to be ready for download use GoogleSearchAdsReportSensor.

airflow/providers/google/marketing_platform/example_dags/example_search_ads.pyView Source

wait_for_report = GoogleSearchAdsReportSensor(report_id=report_id, task_id="wait_for_report")

You can use Jinja templating with report_id, impersonation_chain parameters which allows you to dynamically determine values.

Downloading a report

To download a Search Ads report to Google Cloud Storage bucket use the GoogleSearchAdsDownloadReportOperator.

airflow/providers/google/marketing_platform/example_dags/example_search_ads.pyView Source

download_report = GoogleSearchAdsDownloadReportOperator(
    report_id=report_id, bucket_name=GCS_BUCKET, task_id="download_report"
)

You can use Jinja templating with report_name, report_id, bucket_name, impersonation_chain parameters which allows you to dynamically determine values. The result is saved to XCom, which allows it to be used by other operators.

Was this entry helpful?