Mage supports ingesting data from YouTube Analytics by connecting to the YouTube Analytics API and YouTube Data API v3 using OAuth 2.0 credentials.

This integration allows you to extract rich channel analytics, video performance, and viewer engagement metrics directly into your Mage pipelines.


🔧 Configuration

To connect to the YouTube Analytics API, provide the following parameters in your source configuration:

KeyDescriptionSample ValueRequired
client_idOAuth 2.0 Client ID from Google Cloud Console123456789-abcdef.apps.googleusercontent.com
client_secretOAuth 2.0 Client Secret from Google Cloud Consoleabcdefghijklmnopqrstuvwxyz
refresh_tokenOAuth 2.0 refresh token for authenticating requests1//abcdefghijklmnopqrstuvwxyz
start_dateStart date for pulling analytics data2021-01-01T00:00:00Z
user_agentUser agent string identifying the integrationexample@example.com
channel_idsComma-separated list of channel IDs to retrieve analytics forUC1234..., UC5678...

🔐 How to Generate Credentials

Follow these steps to generate the required credentials from the Google Cloud Console:

1. Set Up OAuth Credentials

  1. Go to Google Cloud Console
  2. Create a new project (or use an existing one)
  3. Enable the following APIs:
    • YouTube Data API v3
    • YouTube Analytics API v2
  4. Navigate to “APIs & Services > Credentials”
  5. Create a new OAuth 2.0 Client ID (select “Web application” or “Desktop app”)

2. Generate a Refresh Token

Use OAuth 2.0 Playground to get a refresh_token:

  • Click the gear icon and check “Use your own OAuth credentials”, then enter your Client ID and Secret.
  • Select the following scopes:
    • https://www.googleapis.com/auth/youtube.readonly
    • https://www.googleapis.com/auth/yt-analytics.readonly
  • Follow the steps to authorize, exchange code for tokens, and copy the refresh token.

How It Works

This integration connects to two key Google APIs to extract YouTube Analytics data and video metadata:

APIs Used

Supported Streams

The following streams are available in the YouTube Analytics integration:

StreamDescription
channelsMetadata and statistics for authenticated YouTube channels
playlist_itemsVideos and items within playlists
playlistsMetadata about playlists created by the authenticated user
reportsBulk analytics data from YouTube Reporting API
videosVideo metadata, engagement, and performance statistics

Sync Behavior

  • Incremental Syncs
    The integration supports stateful incremental loading, so only new or modified records are fetched during each sync run.

  • Schema Output
    Mage automatically generates the output schema for each stream, making it easier to understand and work with the resulting data.