How to Import YouTube Video Details in Google Sheets

As a marketer, I always try to keep track of my product’s performance on social media platforms. YouTube is one of the most popular social media platforms, and it’s essential to keep track of your YouTube channel’s stats to analyze how things are performing.

However, collecting YouTube video details can be a time-consuming task. That’s where Google Sheets comes in handy.

Preview of Results

Google Sheets is a powerful tool that allows you to import YouTube video details such as views, likes, comments, and more, directly into your spreadsheet. This feature is incredibly helpful for marketers who want to analyze their YouTube channel’s performance without having to manually collect the data.

In this article, I will show you how to import YouTube video details in Google Sheets like views, upload date.

You will learn how to create an Apps Script project, add YouTube video URLs, and import the data into your Google Sheets. By the end of this article, you will have a clear understanding of how to use Google Sheets to import YouTube video details and analyze your YouTube channel’s performance.

Above all, if you require any customization on this, feel free to comment below or connect with me.

Table of Contents

Why You Should Collect Data YouTube Data in Sheets?

By collecting data in Google Sheets, you can easily analyze the metrics and gain insights into what’s working and what’s not. This can help you create better content and improve your overall strategy.

Here are a few reasons why you should consider collecting YouTube data in Sheets:

  • You can easily track video views, likes, comments, and other engagement metrics over time.
  • You can compare the performance of different videos and identify trends and patterns.
  • You can use the data to inform your content strategy and create more engaging videos.
  • You can share the data with your team or clients to keep everyone on the same page.

With the right tools and strategies, you can take your YouTube channel to the next level and reach a wider audience.

How to Collect YouTube API Key?

Before we can import YouTube video details in Google Sheets, we need to collect our YouTube API key

Here’s how to do it

Create a Google Cloud Platform Project

Before we can start importing YouTube video details into Google Sheets, we need to create a Google Cloud Platform project. This will allow us to access the YouTube Data API and generate an API key that we can use to make requests to the API.

Creating new Google Cloud Platform Project

To create a new project in Google Cloud Platform, follow these steps:

  1. Go to the Google Cloud Console.
  2. Click on the project dropdown menu at the top of the page, then click on the “New Project” button.
  3. Enter a name for your project in the “Project Name” field.
  4. Choose a billing account for your project. If you don’t have one set up, you’ll need to create one.
  5. Click the “Create” button to create your project.

Once your project is created, you’ll be taken to the project dashboard. From here, you can manage your project’s settings, create credentials, and enable APIs.

Now that we have a project set up, we can move on to creating an API key that we can use to access the YouTube Data API.

Enable YouTube API v3 Key

Enabling YouTube API

In order to import YouTube video details into Google Sheets, we need to enable the YouTube API v3 key. This process involves a few steps, but it is relatively straightforward. Here’s what you need to do:

  1. Go to the Google Developers Console and create a new project or select an existing one.
  2. Once you have selected the project, navigate to the “APIs & Services” section on the left-hand side of the screen.
  3. Click on the “Enable APIs and Services” button at the top of the page.
  4. Search for “YouTube Data API v3” and click on it when it appears in the search results.
  5. Click on the “Enable” button to activate the API for your project.
  6. Next, click on the “Create Credentials” button to generate an API key.
  7. Choose “API key” as the credential type.
  8. Copy the API key and save it somewhere safe. You will need it later when connecting to the YouTube Public API Data Key with Google Sheets.
Getting API Key from YouTube

Enabling the YouTube API v3 key is an essential step in importing YouTube video details into Google Sheets. Once you have completed this step, you will be ready to move on to the next step, which involves connecting to the YouTube Public API Data Key with Google Sheets.

I have also shared how to save Twitter Tweets in Google Sheet for FREE – Read More here

How to Connect YouTube API with Google Sheets?

Now that we have the API key, the next step is to connect them to Google Sheets so that the video details can be displayed. Here are the steps to follow:

Step 1: Create a Google Sheet File

Create a new Google Sheet file and give it a name and save it in your preferred location.

Step 2: Open App script from Extensions

Open the Google Sheet file and click on the menu item “Extensions” then click on “Apps Script”. This will open the Apps Script editor in a new tab.

Opening App Script

Step 3: Copy and Paste the Code

Copy and paste the following code into the editor:

function getVideoDetails() {
  // Replace "Sheet1" with the name of your sheet
  var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("YouTube");

  // Get the range of cells that have the YouTube links
  var range = sheet.getRange("E2:E");  // column A, starting from row 2
  var values = range.getValues();

  // Iterate through the YouTube links
  for (var i = 0; i < values.length; i++) {
    var youtubeLink = values[i][0];
    if (youtubeLink) {
      // Get the video ID from the YouTube link
      var videoId = youtubeLink.match(/(?:https?:\/{2})?(?:w{3}\.)?youtu(?:be)?\.(?:com|be)(?:\/watch\?v=|\/)([^\s&]+)/);
      if (videoId) {
        // Call the YouTube Data API to get the view count, published date, and video title
        var url = "" + videoId[1] + "&key=[YOUR_API_KEY_HERE]&part=snippet,statistics";
        var response = UrlFetchApp.fetch(url);
        var json = response.getContentText();
        var data = JSON.parse(json);
        var viewCount = data.items[0].statistics.viewCount;
        var publishedAt = data.items[0].snippet.publishedAt;
        var videoTitle = data.items[0].snippet.title;
        // Parse the publishedAt date string to a JavaScript Date object
        var date = new Date(publishedAt);
        // Get the day of the month (1-31) from the Date object
        var day = date.getDate();
        // Get the month (0-11) from the Date object and convert it to a string (e.g. "January", "February", etc.)
        var month = date.toLocaleString("default", {month: "long"});
        // Get the full year (e.g. 2020) from the Date object
        var year = date.getFullYear();
        // Concatenate the day, month, and year variables to create the desired date format
        var formattedDate = day + "-" + month + "-" + year;
        // Update the cells with the view count, published date, and video title
        sheet.getRange(i + 2, 6).setValue(viewCount);  // column B, starting from row 2
        sheet.getRange(i + 2, 4).setValue(formattedDate);  // column C, starting from row 2
        sheet.getRange(i + 2, 2).setValue(videoTitle);  // column D, starting from row 2

Note: Replace “YOUR_API_KEY_HERE” with your API key that you obtained earlier.

Pasting App Script Code

The above code will import YouTube video title, view count, published date in 3 columns. If you require any help with this, feel free to connect with me.

Step 4: Running Script to Test the Output

Click on the “Run” button to test the script output. If everything is working correctly, the script will fetch the video details and display them in the Google Sheet file.

Output Stats

That’s it! You have successfully connected YouTube API with Google Sheets and can now import video details into your spreadsheet.

I share my Learnings & Case studies via email.
Subscribe to Stay Updated

How to Automate YouTube Video Data Collection in Sheets using Triggers

If you want to automate the process of collecting YouTube video details in Google Sheets, you can use the inbuilt time-based triggers in Sheets along with App script Triggers page. This allows you to set up triggers that collect data at specific intervals, such as every hour, daily, or weekly.

To get started, open your Google Sheet and click on the “Extensions” menu. From there, select “App Script” This will open a new window where you can create a new script or edit an existing one.

Next, click on the “Triggers” icon in the toolbar. This will open the App script Triggers page, where you can set up a new trigger by clicking on the “Add Trigger” button.

When setting up your trigger, you can choose the function you want to run and the time interval at which you want it to run. For example, you could set up a trigger to run the “getVideoDetails” function every hour.

Enabling Time Based Trigger

Once you’ve set up your trigger, you can save your script and close the Script editor window. Your trigger will now run automatically at the specified intervals, collecting YouTube video details and populating them in your Google Sheet.

Automating data collection using triggers can save you a lot of time and effort, especially if you need to collect data on a regular basis. With just a few clicks, you can set up a trigger that will automatically collect YouTube video details in your Google Sheet, allowing you to focus on more important tasks.


In this article, I have provided step-by-step instructions on how to connect to the YouTube Data API, pull public data from YouTube to Sheets, create a custom API request, handle filtering and pagination, and import YouTube Analytics to Google Sheets.

By following these instructions, you can easily import video details such as views, comments, likes, and dislikes, and use them to create custom reports, charts, and dashboards. You can also use the data to analyze your video performance, identify trends, and make data-driven decisions to improve your content strategy.

However, it is important to note that the YouTube Data API has certain limitations and quotas that you need to be aware of. Make sure to read the API documentation carefully and follow the best practices to avoid any issues.

Frequently Asked Questions

Can I import video details from multiple YouTube channels into one Google Sheet?

Yes, you can import video details from multiple YouTube channels into one Google Sheet. It all depends on the video links you paste

How often can I update the video details in Google Sheets?

You can update the video details in Google Sheets as often as you need. However, keep in mind that the YouTube API limits the number of requests you can make per day. If you exceed the limit, you may need to wait until the next day to update the data.

Can I import the video details of private or unlisted videos?

No, you cannot import the video details of private or unlisted videos using the YouTube API. The API only allows you to access the data of public videos. If you need to import the details of private or unlisted videos, you may need to use other methods.

Can I import video details from a specific playlist?

Yes, you can import video details from a specific playlist using the YouTube API. You need to specify the playlist ID in the API request and then use the IMPORTJSON or other functions to extract the data from the JSON response.

Aditya R Sharma

Hello! Currently, I am working as Chief Marketing Officer at POSIMYTH Innovations, with a deep love for WordPress. I love solving problem with AI, Automations & Critical planning. In my free time, I write blogs to share all his learnings with the internet.

Content Writing for SaaS & WordPress Business
Tired of Low Traffic & see your Blog Fail?

Let me help you with content writing & SEO strategy for your product that makes sales.

After raising multiple domains to 1M+ organic click, I am helping Business owners like you harness the real power of SEO.

Explore Further