Google AdWords Transfers

The BigQuery Data Transfer Service for Google AdWords allows you to automatically schedule and manage recurring load jobs for Adwords reporting data.

Supported Reports

The BigQuery Data Transfer Service for Google AdWords currently supports the following reporting options:

For information on how Google AdWords reports are transformed into BigQuery tables, see Google AdWords Report Transformations.

Reporting option Support
Supported API version

v201705

For information on AdWords API migration, see Migration Guide (v201705).

Schedule

Daily, at the time the Transfer is first created (default)

You can configure the time of day.

Refresh window

Last 7 days

Configurable up to last 30 days

Snapshots of Match Tables are taken once a day and stored in the partition for the latest run date. Match Table snapshots are NOT updated for backfills or for days loaded via the refresh window. For information on which Match Tables are not updated by the refresh window, see Set up a backfill.

Maximum backfill duration

No limit

While AdWords has no known data retention limits, the BigQuery Data Transfer Service has limits on how many days can be requested in a single backfill. For information on backfills, see Set up a backfill.

Before you begin

Before you create a Google AdWords transfer:

  • Verify that you have completed all actions required to enable the BigQuery Data Transfer Service.
  • Create a BigQuery dataset to store the AdWords data.
  • Ensure that you have the following required permissions:
    • Google AdWords: Read access to the AdWords Customer ID that is used in the transfer configuration.
    • Google Cloud Platform: bigquery.transfers.update permission. The bigquery.admin predefined IAM role includes bigquery.transfers.update permissions. For more information on IAM roles in BigQuery, see Access Control.

Setting up an AdWords data transfer

Setting up a data transfer for AdWords reporting requires a:

  • Customer ID: Your customer ID as issued by Adwords. For information on retrieving your AdWords customer ID, see Find your customer ID.

To create a data transfer for AdWords reporting:

Web UI

  1. Go to the BigQuery web UI.

    Go to the BigQuery web UI

  2. Click Transfers.

  3. Click Add Transfer.

  4. On the New Transfer page:

    • For Source, choose AdWords Reports.
    • For Destination, choose the dataset you created to store your AdWords data.
    • For Display Name, enter a name for the transfer such as My Transfer. The transfer name can be any value that allows you to easily identify the transfer if you need to modify it later.
    • For Refresh Window, enter the number of days to incude in the data transfer. If you enter 1, there is no daily backfill. Entering 0 configures the default refresh window of 7 days. The maximum value is 30. For more information, see Determining your data's freshness.
    • For Customer ID, enter your customer ID.
    • Check Exclude Removed/Disabled Items to prevent removed or disabled entities and metrics from being transferred.
    • For Schedule, leave the default value (every 24 hours at transfer creation time).

      Channel transfer

    • (Optional) To change the Schedule, click Edit and change the time.

      Channel transfer

  5. Click Add.

  6. When prompted, click Allow to give the BigQuery Transfer Service permission to manage your AdWords campaigns. You must allow pop-ups from bigquery.cloud.google.com to view the permissions window.

    Allow transfer

Command-line

Enter the bq mk command and supply the transfer creation flag — --transfer_config. The following flags are also required:

  • --data_source
  • --target_dataset
  • --display_name
  • --params

You can also supply the --project_id flag to specify a particular project. If --project_id isn't specified, the default project is used.

    bq mk --transfer_config --project_id=[PROJECT_ID] --target_dataset=[DATASET] --display_name=[NAME] --params='[PARAMETERS]' --data_source=[DATA_SOURCE]

Where:

  • --project_id is your project ID.
  • --target_dataset is the target dataset for the transfer configuration.
  • --display_name is the display name for the transfer configuration. The transfer name can be any value that allows you to easily identify the transfer if you need to modify it later.
  • --params contains the parameters for the created transfer configuration in JSON format. For example: --params='{"param":"param_value"}'. For Google AdWords, you must supply the customer_id parameter. You may optionally set the exclude_removed_items parameter to true to prevent removed or disabled entities and metrics from being transferred.
  • --data_source is the data source — adwords.

For example, the following command creates a Google AdWords transfer named My Transfer using customer ID 123-123-1234 and target dataset mydataset. The transfer is created in the default project:

bq mk --transfer_config --target_dataset=mydataset --display_name='My Transfer' --params='{"customer_id":"123-123-1234","exclude_removed_items":"true"}' --data_source=adwords

The first time you run the command, you receive a message like the following:

[URL omitted] Please copy and paste the above URL into your web browser and follow the instructions to retrieve an authentication code.

Follow the instructions in the message and paste the authentication code on the command line.

API

Use the projects.locations.transferConfigs.create method and supply an instance of the TransferConfig resource.

When your data is transferred to BigQuery, the data is written to date-partitioned tables. For more information, see Partitioned Tables.

Troubleshooting Google AdWords transfer setup

If you are having issues setting up your transfer, see Google AdWords transfer issues in Troubleshooting BigQuery Data Transfer Service Transfer Setup.

AdWords Sample Queries

You can use the following AdWords sample queries to analyze your transferred data. You can also use the queries in a visualization tool such as Google Cloud Datalab or Google Data Studio 360. These queries are provided to help you get started on querying your AdWords data with BigQuery. For additional questions on what you can do with these reports, contact your Google AdWords technical representative.

In each of the following queries, replace [DATASET] with your dataset name. Replace [CUSTOMER_ID] with your AdWords customer ID.

These samples use BigQuery’s support for standard SQL. Use the #standardSQL tag to let BigQuery know you want to use standard SQL. For more information about the #standardSQL prefix, see Setting a query prefix.

If you query your tables directly instead of using the auto-generated views, you must use the _PARTITIONTIME pseudo-column in your query. For more information, see Querying Date-Partitioned Tables.

Campaign performance

The following sample query analyzes AdWords campaign performance for the past 30 days.

Web UI

#standardSQL
SELECT
  c.ExternalCustomerId,
  c.CampaignName,
  c.CampaignStatus,
  SUM(cs.Impressions) AS Impressions,
  SUM(cs.Interactions) AS Interactions,
  (SUM(cs.Cost) / 1000000) AS Cost
FROM
  `[DATASET].Campaign_[CUSTOMER_ID]` c
LEFT JOIN
  `[DATASET].CampaignBasicStats_[CUSTOMER_ID]` cs
ON
  (c.CampaignId = cs.CampaignId
   AND cs._DATA_DATE BETWEEN
   DATE_ADD(CURRENT_DATE(), INTERVAL -31 DAY) AND DATE_ADD(CURRENT_DATE(), INTERVAL -1 DAY))
WHERE
  c._DATA_DATE = c._LATEST_DATE
GROUP BY
  1, 2, 3
ORDER BY
  Impressions DESC

Command-line

bq query --use_legacy_sql=false '
SELECT
  c.ExternalCustomerId,
  c.CampaignName,
  c.CampaignStatus,
  SUM(cs.Impressions) AS Impressions,
  SUM(cs.Interactions) AS Interactions,
  (SUM(cs.Cost) / 1000000) AS Cost
FROM
  `[DATASET].Campaign_[CUSTOMER_ID]` c
LEFT JOIN
  `[DATASET].CampaignBasicStats_[CUSTOMER_ID]` cs
ON
  (c.CampaignId = cs.CampaignId
   AND cs._DATA_DATE BETWEEN
   DATE_ADD(CURRENT_DATE(), INTERVAL -31 DAY) AND DATE_ADD(CURRENT_DATE(), INTERVAL -1 DAY))
WHERE
  c._DATA_DATE = c._LATEST_DATE
GROUP BY
  1, 2, 3
ORDER BY
  Impressions DESC'

Count of keywords

The following sample query analyzes keywords by campaign, ad group, and keyword status. This query uses the KeywordMatchType function. Keyword match types help control which searches can trigger your ad. For more information on keyword matching options, see About keyword matching options.

Web UI

#standardSQL
SELECT
  c.CampaignStatus AS CampaignStatus,
  a.AdGroupStatus AS AdGroupStatus,
  k.Status AS KeywordStatus,
  k.KeywordMatchType AS KeywordMatchType,
  COUNT(*) AS count
FROM
  `[DATASET].Keyword_[CUSTOMER_ID]` k
  JOIN
  `[DATASET].Campaign_[CUSTOMER_ID]` c
ON
  (k.CampaignId = c.CampaignId AND k.DATA_DATE = c._DATA_DATE)
JOIN
  `[DATASET].AdGroup[CUSTOMER_ID]` a
ON
  (k.AdGroupId = a.AdGroupId AND k._DATA_DATE = a._DATA_DATE)
WHERE
  k._DATA_DATE = k._LATEST_DATE
GROUP BY
  1, 2, 3, 4

Command-line

bq query --use_legacy_sql=false '
SELECT
  c.CampaignStatus AS CampaignStatus,
  a.AdGroupStatus AS AdGroupStatus,
  k.Status AS KeywordStatus,
  k.KeywordMatchType AS KeywordMatchType,
  COUNT(*) AS count
FROM
  `[DATASET].Keyword_[CUSTOMER_ID]` k
JOIN
  `[DATASET].Campaign_[CUSTOMER_ID]` c
ON
  (k.CampaignId = c.CampaignId AND k._DATA_DATE = c._DATA_DATE)
JOIN
  `[DATASET].AdGroup_[CUSTOMER_ID]` a
ON
  (k.AdGroupId = a.AdGroupId AND k._DATA_DATE = a._DATA_DATE)
WHERE
  k._DATA_DATE = k._LATEST_DATE
GROUP BY
  1, 2, 3, 4'

Send feedback about...