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

30 days

As of July 2018, YouTube reports containing historical data are available for 30 days from the time that they are generated. (Reports that contain non-historical data are available for 60 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.
  • If you intend to create transfers using the classic 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.

Required permissions

Ensure that the person creating the transfer has the following required permissions:

  • BigQuery:

    • 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.transfers.update permissions. For more information on IAM roles in BigQuery, see Access control.

  • YouTube: Owner of a YouTube channel.

Setting up a YouTube Channel transfer

Setting up a YouTube Channel transfer requires a:

  • 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:

Console

  1. Go to the BigQuery web UI.

    Go to the BigQuery web UI

  2. Click Transfers.

  3. Click + CREATE.

  4. On the Create Transfer page:

    • In the Source type section, for Source, choose YouTube Channel.

      Transfer source

    • In the Transfer config name section, 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.

      Transfer name

    • In the Schedule options section, for Schedule, leave the default value (Start now) or click Start at a set time.

      • For Repeats, choose an option for how often to run the transfer.
        • Daily (default)
        • Weekly
        • Monthly
        • Custom
        • On-demand
      • For Start date and run time, enter the date and time to start the transfer. If you choose Start now, this option is disabled.

        Transfer schedule

    • In the Destination settings section, for Destination dataset, choose the dataset you created to store your data.

      Transfer dataset

    • In the Data source details section:

      • For Customer ID, enter your Customer ID or manager account.
      • Check Exclude removed/disabled Items to prevent removed or disabled entities and metrics from being transferred.

        YouTube Channel source details

    • (Optional) In the Notification options section:

      • Click the toggle to enable email notifications. When you enable this option, the transfer administrator receives an email notification when a transfer run fails.
      • For Select a Cloud Pub/Sub topic, choose your topic name or click Create a topic. This option configures Cloud Pub/Sub run notifications for your transfer. Transfer run notifications are currently in alpha.
  5. Click Save.

Classic 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.
    • For Display name, enter a name for the transfer such as My Transfer.
    • For Schedule, leave the default value or click Edit and change the time.

      Channel transfer custom schedule

    • For Destination dataset, choose the appropriate dataset.

    • 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 Data 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.

      YouTube Channel transfer

    • (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.
      • Don't check Disabled when setting up a transfer. See Working with transfers to disable existing transfers.

        Cloud Pub/Sub topic

  5. Click Add.

  6. When prompted, click Allow to give the BigQuery Data 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 Data 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 Introduction to 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.

¿Te ha resultado útil esta página? Enviar comentarios:

Enviar comentarios sobre...

Si necesitas ayuda, visita nuestra página de asistencia.