No logo available for Google Ads to DuckDB connector icon

Load Google Ads data to DuckDB

Build a Google Ads to DuckDB pipeline with your coding agent. One prompt scaffolds it with the dltHub AI harness, plus the Google Ads API base URL, auth, endpoints, and incremental loading.

SourceGoogle AdsDestinationDuckDBIn-process analytical database. The default local destination for dlt pipelines.

Google Ads API is an interface for managing Google Ads campaigns and accounts programmatically using OAuth 2.0 and a developer token. Everything needed to build a working Google Ads → DuckDB pipeline is on this page: the API's base URL, authentication, endpoints, pagination and incremental field — plus a prompt that hands the whole job to your coding agent.


Build your Google Ads to DuckDB pipeline

Paste this prompt into Claude, Codex, or Cursor. The agent does the rest.

Prompt
Run uvx dlthub-init@latest to build a pipeline from Google Ads to DuckDB and run it on dltHub

That scaffolds a dltHub workspace and installs the dltHub AI harness — the project rules, the secrets-management skill, and the dlt MCP server your agent needs to work safely. From there it reads the Google Ads API, proposes the endpoints to load, then writes, runs and validates the pipeline while you review rather than type. Credentials are inspected through MCP tools, so your agent never reads secrets.toml itself. How the LLM-native workflow works →

Prefer to write it yourself? Every fact the agent uses is below.


Base URLhttps://googleads.googleapis.com
Example endpointPOST customers/{customer_id}/googleAds:search
Records found atresults
Authenticationall requests require a Bearer token and a developer-token header — sent in the Authorization header, prefixed Bearer
Also requireddeveloper-token, login-customer-id, linked-customer-id
PaginationCursor-based
Incremental fieldpageToken
API referencehttps://developers.google.com/google-ads/api/rest/auth

These values come from the Google Ads API reference — the authoritative source if anything here looks out of date.


How do I authenticate with the Google Ads API?

The Google Ads REST API uses OAuth 2.0. Requests require an 'Authorization' header with the format 'Bearer ACCESS_TOKEN' and a 'developer-token' header. An optional 'login-customer-id' header is required when accessing accounts via a manager account.

1. Get your credentials

To obtain credentials for the Google Ads API, you must configure two distinct components: a Developer Token and OAuth 2.0 credentials. 1. Developer Token: Sign in to your Google Ads manager account (MCC), navigate to the API Center (https://ads.google.com/aw/apicenter), and complete the API Access application form. 2. OAuth 2.0 Credentials: Create a project in the Google Cloud Console. Enable the Google Ads API, and configure an OAuth 2.0 client ID (Desktop or Web app) or a service account. Ensure the scope 'https://www.googleapis.com/auth/adwords' is authorized. If using OAuth client IDs, perform the authorization flow to obtain a refresh token. If using service accounts, download the JSON key file and grant the service account access to your Google Ads account via email.

2. Add them to .dlt/secrets.toml

[sources.google_ads_source] developer_token = "YOUR_DEVELOPER_TOKEN" client_id = "YOUR_CLIENT_ID" client_secret = "YOUR_CLIENT_SECRET" refresh_token = "YOUR_REFRESH_TOKEN" login_customer_id = "YOUR_LOGIN_CUSTOMER_ID"

dlt reads this file automatically at runtime. With the harness, the setup-secrets skill prompts you for the values and never handles the raw credential in chat. For production, see setting up credentials with dlt.


What Google Ads data can I load into DuckDB?

These are the Google Ads endpoints dlt can load into DuckDB:

ResourceEndpointMethodData selectorDescription
google_ads_searchcustomers/{customer_id}/googleAds:searchPOSTresultsSearches for resources using GAQL. Pagination required.
google_ads_search_streamcustomers/{customer_id}/googleAds:searchStreamPOSTStreams all results in a single response (no pagination).
mutate_campaignscustomers/{customer_id}/campaigns:mutatePOSTCreates, updates, or removes campaigns.
mutate_ad_groupscustomers/{customer_id}/adGroups:mutatePOSTCreates, updates, or removes ad groups.
mutate_keywordscustomers/{customer_id}/adGroupCriteria:mutatePOSTCreates, updates, or removes ad group criteria.

How do I load only new Google Ads records?

Google Ads exposes pageToken on customers/{customer_id}/googleAds:search, so dlt can request only the records that changed since the last run. Set it as the cursor_path and dlt tracks the high-water mark for you between runs.

{"name": "google_ads_search", "endpoint": { "path": "customers/{customer_id}/googleAds:search", "data_selector": "results", "incremental": {"cursor_path": "pageToken", "initial_value": "2024-01-01T00:00:00Z"}, }}

On the first run dlt loads everything from initial_value; on every run after that it requests only what changed and appends with write_disposition="merge" if you set a primary key. See incremental loading.


What does the generated Google Ads pipeline look like?

A standard dlt REST API pipeline — the same code you would write by hand, loading search and mutate from the Google Ads API into DuckDB:

import dlt from dlt.sources.rest_api import RESTAPIConfig, rest_api_resources @dlt.source def google_ads_source(developer_token=dlt.secrets.value): config: RESTAPIConfig = { "client": { "base_url": "https://googleads.googleapis.com", "auth": {"type": "bearer", "token": developer_token}, }, "resources": [ {"name": "google_ads_search", "endpoint": {"path": "customers/{customer_id}/googleAds:search", "data_selector": "results"}}, {"name": "google_ads_search_stream", "endpoint": {"path": "customers/{customer_id}/googleAds:searchStream"}} ], } yield from rest_api_resources(config) def load_google_ads_to_duckdb() -> None: pipeline = dlt.pipeline( pipeline_name="google_ads_pipeline", destination="duckdb", dataset_name="google_ads_data", ) load_info = pipeline.run(google_ads_source()) print(load_info) if __name__ == "__main__": load_google_ads_to_duckdb()

Run it with python google_ads_pipeline.py. The agent iterates on this until it loads cleanly — you review and approve, rather than write it from scratch.


How do I query Google Ads data in DuckDB?

dlt creates one table per resource. Query the loaded data with Python or SQL — or ask your agent to, through the MCP server's execute_sql_query tool.

Python (pandas DataFrame):

import dlt data = dlt.pipeline("google_ads_pipeline").dataset() df = data.google_ads_search.df() print(df.head())

SQL:

SELECT * FROM google_ads_data.google_ads_search LIMIT 10;

See querying your data with dataset and exploring it in marimo notebooks.


How do I deploy the Google Ads to DuckDB pipeline in production?

The pipeline runs locally, which is ideal for prototyping and one-off analysis. When you need it on a schedule, monitored on every load, and shared with your team, deploy the same dlt code on the dltHub platform — no infrastructure to maintain. The prompt above already ends with "run it on dltHub", so your agent can take it there directly.

  • Deploy & schedule — run the pipeline as a managed job with automatic retries.
  • Monitor — observable job queues, alerting, and load metrics for every run.
  • Transform — promote raw Google Ads loads into governed, documented models.
  • Visualize & share — explore data in notebooks and publish live dashboards instead of static screenshots.

Book a demo →


What other destinations can I load Google Ads data to?

dlt loads into any of these — only the destination argument changes:

DestinationExample value
PostgreSQL"postgres"
BigQuery"bigquery"
Snowflake"snowflake"
Redshift"redshift"
Databricks"databricks"
Filesystem (S3, GCS, Azure)"filesystem"

Set dlt.pipeline(destination="snowflake") and add credentials in .dlt/secrets.toml. On the dltHub platform the same pipeline runs against a managed Iceberg lakehouse. See the full destinations list.


Next steps

Was this page helpful?

Community Hub

Need more dlt context for Google Ads to DuckDB?

Request dlt skills, commands, AGENT.md files, and AI-native context.