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.
Prerequisite Tasks¶
To use these operators, you must do a few things:
Select or create a Cloud Platform project using the Cloud Console.
Enable billing for your project, as described in the Google Cloud documentation.
Enable the API, as described in the Cloud Console documentation.
Install API libraries via pip.
pip install 'apache-airflow[google]'Detailed information is available for Installation.
Inserting a report¶
To insert a Search Ads report use the
GoogleSearchAdsInsertReportOperator
.
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:
report_id = cast(str, XComArg(generate_report, key="report_id"))
Awaiting for a report¶
To wait for a report to be ready for download use
GoogleSearchAdsReportSensor
.
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
.
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.