Skip to content

google-marketing-solutions/ads-policy-monitor

Repository files navigation

Ads Policy Monitor

Providing a 1-stop-shop, centralized view of all your Google Ads policy reports.

Ads Policy Monitor provides a data pipeline for pulling ad and asset approval data from Google Ads, enabling you to monitor trends and spikes with policy approvals.

Solution Overview

To keep ads safe and appropriate for everyone, ads are reviewed to make sure they comply with Google Ads policies, read more here.

For large advertisers and agencies, it can be challenging to monitor the state of your ad copy across all of your Google Ads accounts. This can be amplified when automation is used to create ad copy, as it's easy to introduce mistakes that result in ads being disapproved, for example, the incorrect use of capitalisation.

This solution pulls a daily snapshot of your ad and asset policy approvals, stores them in BigQuery, and provides a Looker Studio dashboard template to monitor this.

When disapprovals happen you can take action by following the deeplink into Google Ads to get more information and take action.

In the dashboard you can instantly monitor the overall status of your accounts: Dashboard overview

And how this changes over time. This allows you to identify any changes in the trend, to investigate further. Dashboard time series

You can drilldown into the disapprovals to try to get more information about why this has happened: Dashboard disapprovals

You're also able to see insights like when an ad group has no approved ads: Dashboard no approved ads

And analyze asset disapprovals: Dashboard assets

How does it work?

Architecture diagram

  1. A daily cron job runs that makes a HTTPS request to trigger the ads_policy_monitor Cloud Function.
  2. The Cloud Function uses Google Ads Query Language (GAQL) to run a number of reports in Google Ads via the API.
  3. The output of these reports is written to a dataset in BigQuery called ads_policy_monitor.
  4. We provide a template Looker Studio dashboard to visualise this data. However, there is nothing to stop you using your own dashboard solution. For example, it is possible to connect this data with the Looker Platform for more advanced BI reporting, alerting, data drilldown etc.

Requirements

Deployment

  1. Open the Google Cloud Project in the UI.
  2. Open the OAuth Consent Screen and create a new internal app.
  3. Open the API Credentials Screen -> Create credentials -> OAuth Client ID -> Web app -> Set https://developers.google.com/oauthplayground as an authorised redirect URI. Make a note of the client_id and the client_secret.
  4. Following OAuth Playground - Generate tokens instructions generate a refresh token for the following scopes, using the client_id and client_secret generated in the previous step:
    https://www.googleapis.com/auth/adwords
    
  5. Open Cloud Shell
  6. Clone the repo & open the directory with the code:
    git clone https://github.com/google-marketing-solutions/ads-policy-monitor.git
    
  7. Go to Terminal -> New Terminal from the menu. Make sure you're in the intended Cloud project. Otherwise, set the shell to use the correct cloud project:
    gcloud config set project [PROJECT ID]
    
  8. In the file editor open up the ads-policy-monitor/terraform/example.tfvars, and update the variables with your configuration (including credentials obtained from Steps 3 and 4).
  9. Run the deployment script in the Terminal:
    sh init.sh
    

Done! Follow the link generated by the deployment script to get your copy of the dashboard. Note: Access to this link is enabled only to users who are part of ads-policy-monitor-template-readers group as stated in the Requirements section.

Please note, the solution is scheduled to run at midnight each day. We recommend waiting for the next day to see the data populated in the dashboard. Alternatively you can force run the job in Cloud Scheduler. However this can create duplicated data if you run more than once a day. Force run Cloud Scheduler screenshot

FAQ

Which Google Cloud APIs will be enabled to my project?

  • Big Query API bigquery.googleapis.com
  • Cloud Build cloudbuild.googleapis.com
  • Cloud Funtions cloudfunctions.googleapis.com
  • Cloud Resource Manager API cloudresourcemanager.googleapis.com
  • Google Ads API googleads.googleapis.com
  • Identity and Access Management (IAM) iam.googleapis.com
  • Secret Manager secretmanager.googleapis.com
  • Cloud Run run.googleapis.com
  • Cloud Scheduler cloudscheduler.googleapis.com

You can also check this on the deployment file ads-policy-monitor/init.sh.

Which GAQL queries are executed?

Please refer to the folder google_ads_queries cloud_functions/ads_policy_monitor/gaql.

Can I deploy it in an existing Cloud Project or do I need to create a new one just for this solution?

You can use an existing Project if you want to. However, please remember that the best practice for clients is to create a new project dedicated to this solution (or any new solution).

Can this solution refresh the data more often than once a day?

You can make the Cloud Scheduler run more often than once a day, however you'd need to also make some customization in the code as the code and templates provided here would show duplicated records.

The reason this solution was designed to run once a day was based on learnings from hundreds of deployments, where the tradeoff between solution costs and Policy Reviews turn-around time was taken into consideration.

If youy still wish to make the refresh rate higher, these are some of the adjustments you'd have to perform:

  1. Introduce time into the event_date parameter of the queries.
  2. Update the cron schedule to run more frequently.
  3. Update the partitioning on the BigQuery table to hourly.
  4. Update the latestadpolicy data query to filter on only the latest data.
  5. Refresh your Looker Studio dashboard data source to mke sure the event_date is now a datetime and instead of just date.

Contributing

Code formatting

The code is formatted using yapf. After making a change, before submitting the code please do the following:

Install the dev requirements:

pip install -r requirements_dev.txt

Then run yapf:

yapf --style google -r -i .

Disclaimers

This is not an officially supported Google product.

Copyright 2024 Google LLC. This solution, including any related sample code or data, is made available on an “as is,” “as available,” and “with all faults” basis, solely for illustrative purposes, and without warranty or representation of any kind. This solution is experimental, unsupported and provided solely for your convenience. Your use of it is subject to your agreements with Google, as applicable, and may constitute a beta feature as defined under those agreements. To the extent that you make any data available to Google in connection with your use of the solution, you represent and warrant that you have all necessary and appropriate rights, consents and permissions to permit Google to use and process that data. By using any portion of this solution, you acknowledge, assume and accept all risks, known and unknown, associated with its usage, including with respect to your deployment of any portion of this solution in your systems, or usage in connection with your business, if at all.