YouTube Channel Transfers

The BigQuery Data Transfer Service for YouTube allows you to automatically schedule and manage recurring load jobs for YouTube Channel reports.

Supported Reports

The BigQuery Data Transfer Service for YouTube Channel reports currently supports the following reporting options:

For information on how YouTube Channel reports are transformed into BigQuery tables and views, see YouTube Channel Report Transformations.

Reporting option Support
Supported API version June 18, 2018
Schedule

Daily, approximately 14:10 UTC

You can configure the time of day

Refresh window

Last 1 day

Not configurable.

Maximum backfill duration

Last 180 days

YouTube retains data for up to 180 days. For more information, see Historical data in the YouTube Reporting API documentation.

Before you begin

Before you create a YouTube Channel transfer:

  • Verify that you have completed all actions required to enable the BigQuery Data Transfer Service.
  • Create a BigQuery dataset to store the YouTube data.
  • Ensure that the person creating the transfer has the following required permissions:
    • YouTube: Owner of a YouTube channel.
    • Google Cloud Platform: bigquery.transfers.update permissions to create the transfer and bigquery.datasets.update permissions on the target dataset. The bigquery.admin predefined, project-level IAM role includes bigquery.transfers.update and bigquery.datasets.update permissions. For more information on IAM roles in BigQuery, see Access Control.
  • If you intend to create transfers using the BigQuery web UI, allow pop-ups from bigquery.cloud.google.com so you can view the permissions window. You must allow the BigQuery Data Transfer Service permission to manage your YouTube reporting data for the transfer to succeed.
  • Transfer run notifications are currently in Alpha. If you intend to setup transfer run notifications for Cloud Pub/Sub, you must have pubsub.topics.setIamPolicy permissions. Cloud Pub/Sub permissions are not required if you just set up email notifications. For more information, see BigQuery Data Transfer Service Run Notifications.

Setting up a YouTube Channel transfer

Setting up a YouTube Channel transfer requires a:

  • Channel Page ID — To retrieve the Page ID of the Google Plus page associated with the channel:
    • Open Google Plus.
    • At the top right of the window, click the account icon, and choose the account associated with your YouTube channel.
    • Retrieve the page id from the end of the URL. For example, if the URL is https://plus.google.com/b/123123123/, the page id is 123123123.
  • Table Suffix — A user-friendly name for the channel provided by you when you set up the transfer. The suffix is appended to the job ID to create the table name, for example [reportTypeId]_[suffix]. The suffix is used to prevent separate transfers from writing to the same tables. The table suffix must be unique across all transfers that load data into the same dataset, and the suffix should be short to minimize the length of the resulting table name.

If you currently use the YouTube Reporting API and have existing reporting jobs, the BigQuery Data Transfer Service loads your report data. If you do not have existing reporting jobs, setting up the transfer automatically enables YouTube reporting jobs.

To create a YouTube Channel transfer:

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 YouTube Channel Reports.
    • For Destination, choose the appropriate dataset.
    • For Display Name, enter a name for the transfer such as My Transfer.
    • For Channel Page ID, enter your channel page ID.
    • For Table Suffix, enter a suffix such as MT.
    • Check Configure Jobs to allow the BigQuery Transfer Service to manage YouTube reporting jobs for you. If there are YouTube reports that don't currently exist for your channel, new reporting jobs are created to enable them.
    • For Schedule, leave the default value.

      Channel transfer default schedule

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

      Channel transfer custom schedule

    • (Optional) Expand the Advanced section and configure run notifications for your transfer. Transfer run notifications are currently in Alpha.

      • For Cloud Pub/Sub topic, enter your topic name, for example, projects/myproject/topics/mytopic.
      • Check Send Email Notifications to allow email notifications of transfer run failures.

        Cloud Pub/Sub topic

  5. Click Add.

  6. When prompted, click Allow to give the BigQuery Transfer Service permission to manage your YouTube reporting data. You must allow pop-ups from bigquery.cloud.google.com to view the permissions window. If you have multiple accounts, you may be prompted to choose your account as well.

    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

    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 YouTube Channel transfers, you must supply the page_id and table_suffix parameters. You may optionally set the configure_jobs parameter to true to allow the BigQuery Transfer Service to manage YouTube reporting jobs for you. If there are YouTube reports that don't currently exist for your channel, new reporting jobs are created to enable them.
  • --data_source is the data source — youtube_channel.

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

For example, the following command creates a YouTube Channel transfer named My Transfer using page ID 123123123, table suffix MT, and target dataset mydataset. The transfer is created in the default project:

bq mk --transfer_config --target_dataset=mydataset --display_name='My Transfer' --params='{"page_id":"123123123","table_suffix":"MT","configure_jobs":"true"}' --data_source=youtube_channel

API

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

Querying your data

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

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 Partitioned Tables.

Troubleshooting YouTube Channel transfer setup

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

Was this page helpful? Let us know how we did:

Send feedback about...