Skip to main content

This is a package you can use to query reporting data from the Google Ads API.

Project description

GoogleAdsQueryTool Latest Version

This is a package you can use to query reporting data from the Google Ads API.

Build status

Build Status

Requirements

  • Python 3.8+

Installation

pip install googleadsquerytool

Features

  • Distributed via PyPI.
  • Wrapper around the Google Ads API for easy reporting.
  • Returns data in the form of a pandas DataFrame.

Example usage

Before installing the library, you will need a developer token and client customer ID. Instructions on how to obtain them are outlined here. After you have successfully obtained your developer token and have successfully authenticated as per these instructions you need to create a .yaml file (example) and place it in the home directory of your computer or virtual private server.

from googleadsquerytool import create_dict, GoogleAdsDataRetriever

# These represent your SELECT fields for a GAQL query:
fields = ['campaign.name', 'metrics.impressions', 'metrics.cost_micros', 'metrics.clicks']

# This represents the FROM portion of your GAQL query:
resource_name = 'campaign'

# Additional where clauses can be passed but are not mandatory
custom_where_clause = 'campaign.status = "ENABLED" AND campaign.serving_status = "SERVING"'

# Dictionary to append rows into:
ads_data = create_dict(fields)

# Create client object:
client = GoogleAdsDataRetriever(customer_id='Customer_id_that_your_mcc_account_has_access_to')

# Make a request to the API:
google_ads_data_df = client.get_data(
   query_fields=ads_data, 
   from_resource_name=resource_name, 
   headers=False, # Pass a list of headers that you would like to have
   start_date='2024-01-01',
   end_date='2024-01-31', 
   where=custom_where_clause, 
   remove_zero_impressions=True)

For some queries, such as those involving campaign labels, start and end dates cannot be specified, nor can zero-impression rows be removed. In these cases, you can leave these fields blank.

fields = ['campaign.name', 'label.name', 'label.status', 'label.text_label.background_color']

resource_name = 'campaign_label'

label_data = create_dict(fields)

Header_names = ['Campaign', 'Label', 'Label Status', 'Label Color']

label_df = client.get_data(
   query_fields=label_data,
   from_resource_name=resource_name,
   headers=Header_names,
   remove_zero_impressions=False)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

googleadsquerytool-0.1.7.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

googleadsquerytool-0.1.7-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file googleadsquerytool-0.1.7.tar.gz.

File metadata

  • Download URL: googleadsquerytool-0.1.7.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.10.0 Darwin/24.5.0

File hashes

Hashes for googleadsquerytool-0.1.7.tar.gz
Algorithm Hash digest
SHA256 8c45f24dacffb9d6d0f9084b0f5242cda0cde7940d7f27d27c5410629580ae8d
MD5 5d1994d07d3db7bf01f19e71b5e40613
BLAKE2b-256 61a3ebcc61ad0f9b6546453901928c503bdc8c6786f35bc8b95b068e3d75ecc4

See more details on using hashes here.

File details

Details for the file googleadsquerytool-0.1.7-py3-none-any.whl.

File metadata

File hashes

Hashes for googleadsquerytool-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 cea79d5da9e430231ba82f6a724a038498a6d7734370d43258802b70f485aec8
MD5 20c0b2e78c052f2722b43b79d84e970d
BLAKE2b-256 4af8529dc8c87325d8b36d5369438ba3b4336110183a7794d60cf757145f29c8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page