Marketing · n8n

Automatically Log Daily YouTube Analytics to Google Sheets

An n8n workflow that pulls yesterday's views, watch time and subscriber change from the YouTube Analytics API every morning and appends them to a Google Sheet — giving creators a growing dashboard of channel performance without ever opening YouTube Studio.

difficulty Advancedsetup 60 minresult A daily row of channel KPIs building into a trend chart you fully own
  1. 1

    Set up the OAuth2 credential

    In Google Cloud, enable the YouTube Analytics API and create an OAuth2 client. In n8n, add a Google OAuth2 API credential with scope https://www.googleapis.com/auth/yt-analytics.readonly and authorize it. This lets n8n read your private channel metrics securely.

  2. 2

    Schedule the morning run

    Add a Schedule Trigger set to Days at hour 6. Reporting one day behind is normal — YouTube finalizes yesterday's numbers overnight, so a 6 AM run captures clean, settled data.

  3. 3

    Query the Analytics API

    An HTTP Request node (using the OAuth2 credential) calls https://youtubeanalytics.googleapis.com/v2/reports with ids=channel==MINE, startDate and endDate both set to yesterday via {{$today.minus({days:1}).toFormat('yyyy-MM-dd')}}, and metrics=views,estimatedMinutesWatched,averageViewDuration,subscribersGained,subscribersLost.

  4. 4

    Shape the row

    A Set node maps the API's rows[0] array into named fields — date, views, watch minutes, avg view duration, subs gained, subs lost, and a computed net_subs. Naming them here keeps the Sheet columns tidy and self-documenting.

  5. 5

    Append to your dashboard sheet

    A Google Sheets node appends the row. Insert a line chart over the date/views columns once and it grows automatically. You now own a permanent, exportable record of channel growth independent of YouTube Studio's rolling windows.

Frequently asked questions

Why is this rated Advanced?

The YouTube Analytics API needs OAuth2 (not just an API key) because it reads private channel data. Setting up the OAuth consent screen and credential in Google Cloud is the fiddly part. Once the n8n OAuth2 credential is connected, the rest of the workflow is straightforward HTTP + Sheets.

Which metrics can I pull?

The reports endpoint supports dozens: views, estimatedMinutesWatched, averageViewDuration, subscribersGained, subscribersLost, likes, comments, shares and more. The example pulls the core five, but you just extend the `metrics` query parameter with a comma-separated list to track whatever you care about.

Can I chart the results automatically?

Google Sheets can build a live chart from the growing range with no extra setup — insert a chart once and it expands as rows append. If you'd rather push to a BI tool, add a second branch that also writes to BigQuery or sends the row to a Looker Studio data source.

About this recipe. Recipes on FlowRecipesHub are written for business owners, not developers, and are tested before publishing — how recipes get made. Some ingredient links are affiliate links that cost you nothing — full disclosure.