AutomationFlowsSocial Media › Track Top Youtube Videos by View Count with Google Sheets

Track Top Youtube Videos by View Count with Google Sheets

ByTaiki @taiki on n8n.io

This workflow collects the most-viewed videos from specified YouTube channels and saves the data to a Google Sheet. Follow these steps to set it up:

Event trigger★★★★☆ complexity11 nodesHTTP RequestGoogle Sheets
Social Media Trigger: Event Nodes: 11 Complexity: ★★★★☆ Added:

This workflow corresponds to n8n.io template #5668 — we link there as the canonical source.

This workflow follows the Google Sheets → HTTP Request recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "id": "M0TnkjeDHSBlsVLQ",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Add the most popular videos from a specific YT channel to sheets",
  "tags": [],
  "nodes": [
    {
      "id": "038873e2-0e74-4644-be10-b485c1e40d81",
      "name": "When clicking \u2018Execute workflow\u2019",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -160,
        60
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "1a8d863a-8c74-4f94-9adf-503ca37ad584",
      "name": "Fetch Most-Viewed Videos via YouTube API",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        300,
        40
      ],
      "parameters": {
        "url": "https://www.googleapis.com/youtube/v3/search",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "key",
              "value": "YOUR_YOUTUBE_API_KEY"
            },
            {
              "name": "part",
              "value": "snippet"
            },
            {
              "name": "channelId",
              "value": "={{ $json.ChannelID }}"
            },
            {
              "name": "maxResults",
              "value": "={{ $json.video_num_to_get }}"
            },
            {
              "name": "order",
              "value": "viewCount"
            },
            {
              "name": "type",
              "value": "video"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "69553f6a-c563-4389-9618-3b402e497e3b",
      "name": "Read Channel Info from Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        80,
        40
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_INPUT_SHEET_NAME"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_SPREADSHEET_ID"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "6b51fd78-6868-41a6-90de-fb7ba05db9cc",
      "name": "Split Into Individual Videos",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        520,
        40
      ],
      "parameters": {
        "include": "allOtherFields",
        "options": {},
        "fieldToSplitOut": "items"
      },
      "typeVersion": 1
    },
    {
      "id": "5fa2c6ec-6b92-4ba4-9ab6-37718d3354af",
      "name": "Append Video Details to Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        740,
        40
      ],
      "parameters": {
        "columns": {
          "value": {
            "title": "={{ $json.items.snippet.title }}",
            "videoId": "={{ $json.items.id.videoId }}",
            "videoLink": "=https://www.youtube.com/watch?v={{ $json.items.id.videoId }}",
            "channelName": "={{ $json.items.snippet.channelTitle }}"
          },
          "schema": [
            {
              "id": "channelName",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "channelName",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "title",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "title",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "videoId",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "videoId",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "videoLink",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "videoLink",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_OUTPUT_SHEET_NAME"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_SPREADSHEET_ID"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "a494ab3e-f3ba-446c-a7b9-c347c34d9cc8",
      "name": "Setup Instructions & Guide",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -480,
        -220
      ],
      "parameters": {
        "content": "## this is note\n\nplease write how to use this node in markdown here!"
      },
      "typeVersion": 1
    },
    {
      "id": "43af9899-b3cb-4300-8bbd-38142457b3fa",
      "name": "Fetch Most-Viewed Videos via YouTube API1",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1820,
        760
      ],
      "parameters": {
        "url": "https://www.googleapis.com/youtube/v3/search",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "key",
              "value": "YOUR_YOUTUBE_API_KEY"
            },
            {
              "name": "part",
              "value": "snippet"
            },
            {
              "name": "channelId",
              "value": "={{ $json.ChannelID }}"
            },
            {
              "name": "maxResults",
              "value": "={{ $json.video_num_to_get }}"
            },
            {
              "name": "order",
              "value": "viewCount"
            },
            {
              "name": "type",
              "value": "video"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "b9efce22-129d-4971-a6d5-ddc1a46757b3",
      "name": "Read Channel Info from Sheet1",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1600,
        760
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_INPUT_SHEET_NAME"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_SPREADSHEET_ID"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "edc478de-26a7-4a2e-be8e-fa7a47b3da30",
      "name": "Split Into Individual Videos1",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        2040,
        760
      ],
      "parameters": {
        "include": "allOtherFields",
        "options": {},
        "fieldToSplitOut": "items"
      },
      "typeVersion": 1
    },
    {
      "id": "81ec042b-6a6c-48af-8b68-03c90366c87c",
      "name": "Append Video Details to Sheet1",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2260,
        760
      ],
      "parameters": {
        "columns": {
          "value": {
            "title": "={{ $json.items.snippet.title }}",
            "videoId": "={{ $json.items.id.videoId }}",
            "videoLink": "=https://www.youtube.com/watch?v={{ $json.items.id.videoId }}",
            "channelName": "={{ $json.items.snippet.channelTitle }}"
          },
          "schema": [
            {
              "id": "channelName",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "channelName",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "title",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "title",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "videoId",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "videoId",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "videoLink",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "videoLink",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_OUTPUT_SHEET_NAME"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_SPREADSHEET_ID"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "178043b9-528c-45bc-956c-98663bad69b2",
      "name": "Setup Instructions & Guide1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1040,
        500
      ],
      "parameters": {
        "width": 500,
        "height": 1460,
        "content": "## Workflow Setup Guide\n\nThis workflow collects the most-viewed videos from specified YouTube channels and saves the data to a Google Sheet. Follow these steps to set it up:\n\n## 1. Credentials Setup\n\n*   **Google Sheets:** You need to have a Google Sheets credential configured in your n8n instance. If you don't have one, go to the 'Credentials' section in n8n and add a new credential for Google Sheets.\n*   **YouTube API Key:** You need a YouTube Data API v3 key.\n    1.  Go to the [Google Cloud Console](https://console.cloud.google.com/).\n    2.  Create a new project or select an existing one.\n    3.  Go to 'APIs & Services' > 'Library' and enable the **YouTube Data API v3**.\n    4.  Go to 'APIs & Services' > 'Credentials', click 'Create Credentials', and choose 'API key'.\n    5.  Copy the generated API key.\n\n## 2. Google Sheet Setup\n\nYou will need one Google Sheet with two separate sheets (tabs) inside it.\n\n### Input Sheet\nUse [Template](https://docs.google.com/spreadsheets/d/1EwALToSWKp4EyzPCx4q3rhMHMaJ3MMfwXQoZmC2BWZk/edit?usp=sharing)\nThis sheet provides the list of YouTube channels to process.\n*   **Required Columns:** Create a sheet with the following two columns:\n    *   `ChannelID`: The ID of the YouTube channel (e.g., `T7M3PpjBZzw`).\n    *   `video_num_to_get`: The number of top videos to retrieve for that channel (e.g., `5`).\n\n### Output Sheet\nThis sheet is where the results will be saved.\n*   **Required Columns:** The workflow will automatically append data to the following columns. You can create them beforehand or let the workflow do it.\n    *   `channelName`\n    *   `title`\n    *   `videoId`\n    *   `videoLink`\n\n## 3. Node Configuration\n\n*   **Read Channel Info from Sheet:** \n    *   Select your Google Sheets credential.\n    *   Enter your **Spreadsheet ID**.\n    *   Enter the **name of your Input Sheet**.\n*   **Fetch Most-Viewed Videos via YouTube API:** \n    *   Replace `YOUR_YOUTUBE_API_KEY` with the API key you generated in Step 1.\n*   **Append Video Details to Sheet:**\n    *   Select your Google Sheets credential.\n    *   Enter your **Spreadsheet ID** (the same one as before).\n    *   Enter the **name of your Output Sheet**."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "f642b6b7-f174-4ea0-9e8c-ad033597d947",
  "connections": {
    "Read Channel Info from Sheet": {
      "main": [
        [
          {
            "node": "Fetch Most-Viewed Videos via YouTube API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Into Individual Videos": {
      "main": [
        [
          {
            "node": "Append Video Details to Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read Channel Info from Sheet1": {
      "main": [
        [
          {
            "node": "Fetch Most-Viewed Videos via YouTube API1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Into Individual Videos1": {
      "main": [
        [
          {
            "node": "Append Video Details to Sheet1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking \u2018Execute workflow\u2019": {
      "main": [
        [
          {
            "node": "Read Channel Info from Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Most-Viewed Videos via YouTube API": {
      "main": [
        [
          {
            "node": "Split Into Individual Videos",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Most-Viewed Videos via YouTube API1": {
      "main": [
        [
          {
            "node": "Split Into Individual Videos1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

This workflow collects the most-viewed videos from specified YouTube channels and saves the data to a Google Sheet. Follow these steps to set it up:

Source: https://n8n.io/workflows/5668/ — original creator credit. Request a take-down →

More Social Media workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

Social Media

This n8n workflow automates the process of uploading video and image advertisements to Meta Ads Manager via the Meta Graph API (Facebook Ads) directly from Google Sheets and Google Drive. The workflow

Facebook Graph Api, Google Sheets, HTTP Request +2
Social Media

This workflow provides an end-to-end automation for discovering, evaluating, and optionally downloading high-quality educational YouTube videos.

HTTP Request, Google Sheets
Social Media

• Downloads videos/music from YouTube using yt-dlp • Merges assets with dynamic text overlays • Automatically uploads to YouTube as Shorts (9:16 format) • Tracks everything in Google Sheets Install yt

Google Sheets, Execute Command, Read Write File +1
Social Media

This workflow contains community nodes that are only compatible with the self-hosted version of n8n.

HTTP Request, Google Sheets, Google Drive +1
Social Media

This workflow is perfect for digital content creators, marketers, and social media managers who regularly create engaging short-form videos featuring inspirational or motivational quotes. While the wo

Google Sheets, Google Drive, Read Write File +2