Google Ads is an online advertising platform that allows businesses to promote their products and services through digital ads across millions of Google partner websites and its services such as Google Search, YouTube, and Maps. This integration allows you to import Google Ads reports and metrics into Treasure Data to tailor-made your customer experiences, make data-driven decisions to optimize your campaigns, and achieve better marketing results
- Basic knowledge of Treasure Data™
- Basic understanding of Google Ads performance data
- The import job could fail if the data is too big. Using paging could fix that problem.
- Google might change the default views of its performance data from time to time, thus the below pre-defined metric collection of each report type might not be the same as the corresponding reports found on the Google Ads. However, missing metrics could be added to fulfill the data requirement.
- This article doesn't intend to list all available attributes, segments, metrics, and explanations for them. For more details, please refer to Google Ads Query Builder, or the Report Editor feature which can be found on the Google Ads UI (Campaigns > Insights and reports > Report Editor)
You must create and configure the data connection on TD Console before importing data. As part of the data connection, you provide the OAuth authentication of your Google Ads account to deploy the integration using the following steps.

- Open TD Console
- Navigate to Integrations Hub > Catalog
- Search for and select Google Ads V2
- Select Create Authenticationand provide the OAuth of a Google account with access to the target Google Ads account
- After being redirected back to the Integration Hub, repeat the above steps (this time your provided OAuth will be shown), enter a name for your authentication, and select Done.
- Open TD Console
- Navigate to Integrations Hub > Authentications
- Locate your new authentication and select New Source
- On the first step
**1 - Connection**, type a source name in the Data Transfer Name field, and select Next
Identify what data to be ingested into Treasure Data using the parameters below, and select Next.
This integration supports flexible ways to define your target data:
- Choose one of the 4 pre-defined report types, and pick up the desired Attributes, Segments, and Metrics. Or,
- Fill in a custom query valid for Google Ads to import necessary data. It is recommended to use this option together with the Google Ads Query Builder

Source Table Parameter
| Parameter | Required | Type | Description |
|---|---|---|---|
| Ads Account | Required | string | The ID of the target Google Ads account, with or without dashes |
| Ads Manager Account | Optional | string | The ID of the Google Manager account. This is required if the Ads Account is accessible via a manager account. |
| Enable Custom Query | Required | boolean | With this option enabled, a custom query can be used to declare the target data source. Refer to Google Ads Query Builder for more details. Otherwise, choose one of the pre-defined report types, and pick up the desired Attributes, Segments, and Metrics. |
| Report Type | Optional | string | Required if the Custom Query option is disabled. Each pre-defined report type will have its collections of Attributes, Segments, and Metrics. - Ad Performance (similar to the dashboard found on Campaigns > Campaigns > Ads) - Ad Group Performance (similar to the dashboard found on Campaigns > Campaigns > Ad groups) - Campaign Performance (similar to the dashboard found on Campaigns > Campaigns > Campaigns) - Keywords Performance (similar to the dashboard found on Campaigns > Audiences, keywords and content > Search keywords) |
| Include Negative Keywords | Optional | boolean | Enable negative keywords to ingest when the report type is Keywords Performance Report |
| Use predefined metrics | Optional | boolean | Use predefined metrics of the selected report type, instead of adding additional metrics |
| Attributes | Optional | array of string | List of additional attributes for the selected report type |
| Segments | Optional | array of string | At least 1 segment must be added for all the predefined report types. Only time segment is supported: Date, Day of week, Week, Month, Quarter, Year. When the Date Range is All Time, no time segment is required. Otherwise, one type of time segment is needed. |
| Metrics | Optional | array of string | List of additional metrics for the selected report type |
| Date Range | Optional | string | The date range of the target data. Supported values: - Custom Date: define your target range using Start Date and End Date - Today, Yesterday - Last 7 days, Last business week - This month, Last month - All time - Last 14 days, Last 30 days - This week from the previous Sunday to today - This week from the previous Monday to today - Last week from the previous Sunday to Saturday |
| Start Date | Optional | date | The start date of the custom date range in yyyy-MM-dd format |
| End Date | Optional | date | The end date of the custom date range in yyyy-MM-dd format |
| Incremental mode | Optional | boolean | Enable to run the job in incremental mode |
Source Table Parameter - Custom Query
| Parameter | Required | Type | Description |
|---|---|---|---|
| Select Columns | Optional | string | A comma-separated list of fields to query. It should include necessary attributes, segments, and metrics. |
| From Target | Optional | string | The target resource name. It will be used in the FROM clause of the query statement. |
| Other Conditions | Optional | string | Other conditions for the query. It will be used in the WHERE clause of the query statement. |
| Enable Date Range | Optional | boolean | Enable query by date range option. Disabling this option requires that Other Conditions starts with the WHERE keyword. Disabling this option also disables Incremental mode, Start Date, and End Date. |
Optionally, you can modify advanced data settings. Select Next to move to the next step.

| Parameter | Required | Type | Description |
|---|---|---|---|
| Retry Limit | Required | int | Internal maximum retries limit. Default: 5 times. |
| Initial retry time wait in millis | Required | int | Initial retry waiting time in milliseconds. Default: 500ms. |
| Max retry wait in millis | Required | int | Maximum retry waiting time in milliseconds. Default: 300,000ms. |
- On the
**4 - Data Preview**step, select Generate Preview to see an approximated view of your data before running the import (optional) - Select Next to continue

For data placement, select the target database and table where you want your data placed and indicate how often the import should run.
Select Next. Under Storage, you will create a new or select an existing database and create a new or select an existing table for where you want to place the imported data.
Select a Database > Select an existing or Create New Database.
Optionally, type a database name.
Select a Table> Select an existing or Create New Table.
Optionally, type a table name.
Choose the method for importing the data.
- Append (default)-Data import results are appended to the table. If the table does not exist, it will be created.
- Always Replace-Replaces the entire content of an existing table with the result output of the query. If the table does not exist, a new table is created.
- Replace on New Data-Only replace the entire content of an existing table with the result output when there is new data.
Select the Timestamp-based Partition Key column. If you want to set a different partition key seed than the default key, you can specify the long or timestamp column as the partitioning time. As a default time column, it uses upload_time with the add_time filter.
Select the Timezone for your data storage.
Under Schedule, you can choose when and how often you want to run this query.
- Select Off.
- Select Scheduling Timezone.
- Select Create & Run Now.
- Select On.
- Select the Schedule. The UI provides these four options: @hourly, @daily and @monthly or custom cron.
- You can also select Delay Transfer and add a delay of execution time.
- Select Scheduling Timezone.
- Select Create & Run Now.
After your transfer has run, you can see the results of your transfer in Data Workbench > Databases.
Prerequisites:
- TD Toolbelt: install the latest version of the TD CLI tool: TD Toolbelt
- Authentication ID: follow the steps above to create an Authentication for this integration on the TD Console. Then the ID could be seen at the last portion of its URL on the Authentication screen.

General steps:
- Create a YML configuration file, ex:
**load.yml**, referencing the created authentication in the `td_authentication_id' field. Refer to the below Parameter Reference and Example for more details - Preview the input data (optional) using the command:
$ **td connector:preview** load.yml - Trigger the data import using the command:
$ **td** **connector:issue** load.yml --database db-name --table table-name - Schedule the execution using the command:
$ **td** **connector:create** daily\_import "10 0 \* \* \*" db-name table-name load.yml
Refer to this page for more reference information
| Name | Description | Value | Default Value | Required |
|---|---|---|---|---|
| client_customer_id | Client customer ID | String | True | |
| login_customer_id | Ads Manager Account ID. This is required if the Ads Account is accessible via a Google Manager account. | String | False | |
| target | Predefined report type. Used when enable\_custom\_query is false. | String | - ad_performance_report - adgroup_performance_report - campaign_performance_report - keywords_performance_report | False |
| segments | List of additional segments. Used when enable\_custom\_query is false. When the date\_range is ALL_TIME, no time segment is required Otherwise, one type of time segment is needed. time segment is supported: Date, Day of week, Week, Month, Quarter, Year | Array of String | False | |
| include_predefined_metrics | Include all predefined metrics Used when enable\_custom\_query is false. | Boolean | True | False |
| metrics | List of additional metrics. Used when enable\_custom\_query is false. | Array of String | False | |
| attributes | List of additional attributes. Used when enable\_custom\_query is false | Array of String | False | |
| incremental | Run the job in incremental mode | Boolean | False | False |
| incremental_duration | Duration in days for the incremental job. Ignore end_date and recalculate it by this formula: end_date = start_date + incremental_duration | Integer | 0 | False |
| data_range | The date range of the target data. Refer to here for supported values | String | ||
| start_date | Start date, used with date\_range is custom\_date | Date | False | |
| end_date | End date, used with date\_range is custom\_date | Date | False | |
| include_negative_keywords | Filter the records by negative keywords, only used with keywords_performance_report | False | False | False |
| enable_custom_query | Enable the use of custom query | Boolean | False | True |
| select_columns | List of fields to query, separated by comma | String | False | |
| from_target | Report target name | String | False | |
| other_conditions | The other condition of the query | String | False | |
| enable_date_rage | Enable data range query and incremental mode | Boolean | True | False |
| td_authentication_id | The ID of an Authentication created on the TD Console | String | Enable query by date range option. Disable this option will require Other Conditions to start with WHERE keyword. Disable this option also disable Incremental mode, Start Date, and End Date also | True |
| refresh_token | The authentication info is required, and it is more convenient to create it on the UI and then refer to its ID using the above parameter. Alternatively, you can create a Google API project to provide the credential information required for these four parameters. | String | False | |
| client_id | String | False | ||
| client_secret | String | False |
in:
type: google_adwords_v2
td_authentication_id: 330392
enable_custom_query: false
client_customer_id: xx-xxxx-xxxx
target: AD_PERFORMANCE_REPORT
date_range: "CUSTOM_DATE"
include_predefined_metrics: false
incremental: true
start_date: 2020-03-01
end_date: 2020-03-02
segments: ["segments.date"]
metrics: ["metrics.absolute_top_impression_percentage"]
out:
mode: appendin:
type: google_adwords_v2
td_authentication_id: 330392
enable_custom_query: true
client_customer_id: xx-xxxx-xxxx
date_range: "CUSTOM_DATE"
enable_date_range: true
incremental: true
start_date: 2020-03-01
end_date: 2020-03-02
select_columns: ad_group_criterion.criterion_id, ad_group.id, ad_group.name, segments.date
from_target: keyword_view
other_conditions: "AND ad_group_criterion.type = 'KEYWORD'"
out:
mode: appendin:
type: google_adwords_v2
td_authentication_id: 330392
enable_custom_query: true
client_customer_id: xx-xxxx-xxxx
login_customer_id: xx-xxxx-xxxx
date_range: "CUSTOM_DATE"
incremental: true
start_date: 2020-03-01
end_date: 2020-03-02
select_columns: ad_group_criterion.criterion_id, ad_group.id, ad_group.name, segments.date
from_target: keyword_view
other_conditions: "AND ad_group_criterion.type = 'KEYWORD'"
out:
mode: appendYou can import data from Google Ads by using the TD Workflow. Refer here for more detailed information.
Query language reference: https://developers.google.com/google-ads/api/docs/query/overview?hl=en
Example:
SELECT
campaign.id,
campaign.name,
campaign.status,
metrics.impressions,
segments.date,
FROM campaign
WHERE segments.date during LAST_30_DAYS
AND campaign.status = 'PAUSED'
AND metrics.impressions > 1000
ORDER BY campaign.id
in: type: google_adwords_v2 enable_custom_query: true client_id: xxx client_secret: xxx refresh_token: xxx client_customer_id: xx-xxxx-xxxx date_range: "LAST_30_DAYS" developer_token: xxx select_columns: campaign.id, campaign.name, campaign.status, metrics.impressions, segments.date from_target: campaign other_conditions: "AND campaign.status = 'PAUSED' AND metrics.impressions > 1000"
in: type: google_adwords_v2 enable_custom_query: true client_id: xxx client_secret: xxx refresh_token: xxx client_customer_id: xx-xxxx-xxxx login_customer_id: xx-xxxx-xxxx date_range: "LAST_30_DAYS" developer_token: xxx select_columns: campaign.id, campaign.name, campaign.status, metrics.impressions, segments.date from_target: campaign other_conditions: "AND campaign.status = 'PAUSED' AND metrics.impressions > 1000"Note: The query should have time and it should present the where condition, other_conditions should start with AND as in the example.
| Report Type | Predefined Metrics |
|---|---|
| Ad Performance AdGroup Performance Campaign Performance |
|
| Keywords Performance |
|
| Date Range | Description |
|---|---|
| TODAY | Today only. |
| YESTERDAY | Yesterday only. |
| LAST_7_DAYS | The last 7 days not including today. |
| LAST_WEEK | The seven-day period starting with previous Monday. |
| LAST_BUSINESS_WEEK | The 5-day business week, Monday through Friday, of the previous business week. |
| THIS_MONTH | All days in the current month. |
| LAST_MONTH | All days in the previous month. |
| ALL_TIME | The entire available time range. |
| CUSTOM_DATE | A custom date range. Need start_date and end_date in yyyy-MM-dd. |
| LAST_14_DAYS | The last 14 days not including today. |
| LAST_30_DAYS | The last 30 days not including today. |
| THIS_WEEK_SUN_TODAY | The period between the previous Sunday and the current day. |
| THIS_WEEK_MON_TODAY | The period between the previous Monday and the current day. |
| LAST_WEEK_SUN_SAT | The seven-day period starting with the previous Sunday. |