On a schedule
Export YouTube video stats to Google Sheets
Every Sunday night a Videos tab is rewritten with every upload on the channel: title, publish date, duration, views, likes, comments and link.
- Runs
- On a schedule
- Apps
- Google Sheets, YouTube
- AI
- Not needed
- Access
- youtube.readonly; Google Sheets read+write
Send this to your assistant
Create a ClickRuntime automation: every Sunday at 10pm, refresh the Videos tab of my sheet with all videos on my YouTube channel and their publish date, duration, views, likes, comments and link.
First time? Adding ClickRuntime to your assistant takes about two minutes.
Why use it
Why teams use this automation
YouTube Studio is built to look at one video or one period at a time. When you want to compare all your videos at once, such as long against short or this year's uploads against last year's, you need the numbers in a spreadsheet.
This automation rewrites a Videos tab every week with every upload on your channel, its publish date, length, views, likes and comments, sorted by views.
Creators planning their next videos, brand channel managers and agencies reporting to clients use it as their master list of videos.
What you get out of it
Every video in one table
Compare all uploads at once rather than scrolling Studio.
Find what works
Sort or filter by length, topic or year to see which formats get the most views.
Engagement side by side
Likes and comments per view point to videos that connected with viewers.
Fresh every week
The tab is rebuilt each Sunday, so numbers stay current.
Built on your channel login
Your Google connection reads your own channel; no extra API keys are needed.
How it works
What happens, step by step
Every Sunday night ClickRuntime finds your channel's uploads list.
It goes through every video and fetches views, likes, comments and duration in batches of 50.
The Videos tab is cleared and rewritten, most viewed first, with a link to each video.
Before it runs live
- Connect your Google Sheets account and pick the spreadsheets it may use
- Connect YouTube
What you get
Build your own
Need it to work differently?
Your own rules
Conditions, thresholds, filters and exceptions, written the way you'd explain them to a colleague.
Any number of apps
One automation can read from one app and update several others. Over 248 apps are ready, and anything with an API works too.
AI where it helps
Summaries, classification, extraction and drafts use ClickRuntime's built-in AI, with no extra key.
On a schedule or on each event
Runs as often as every 5 minutes, or the moment an app sends an event, and keeps track of what it already handled.
Changes you can ask for
- Run it at a different time, more or less often, or only on weekdays
- Add an AI step, for example to summarize, sort or draft a reply
- Add another app, for example also send it to Slack
- Combine it with other Google Sheets and YouTube steps into one automation
Under the hood
The code that runs this automation
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build
import re
from clickruntime import on_trigger, credentials, report_fetched
SHEET_ID = "your-spreadsheet-id"
def duration(iso):
h, m, s = (int(x or 0) for x in re.match(r"PT(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?", iso).groups())
return f"{h}:{m:02}:{s:02}" if h else f"{m}:{s:02}"
@on_trigger
def run(event):
creds = Credentials(credentials.connection("google", "work"))
yt = build("youtube", "v3", credentials=creds, cache_discovery=False)
uploads = yt.channels().list(part="contentDetails", mine=True).execute()["items"][0]["contentDetails"]["relatedPlaylists"]["uploads"]
ids, token = [], None
while True:
page = yt.playlistItems().list(part="contentDetails", playlistId=uploads, maxResults=50, pageToken=token).execute()
ids += [i["contentDetails"]["videoId"] for i in page["items"]]
token = page.get("nextPageToken")
if not token:
break
report_fetched(len(ids))
rows = []
for i in range(0, len(ids), 50):
for v in yt.videos().list(part="snippet,statistics,contentDetails", id=",".join(ids[i:i + 50])).execute()["items"]:
s = v["statistics"]
rows.append([v["snippet"]["title"], v["snippet"]["publishedAt"][:10], duration(v["contentDetails"]["duration"]),
int(s.get("viewCount", 0)), int(s.get("likeCount", 0)), int(s.get("commentCount", 0)), f"https://youtu.be/{v['id']}"])
rows.sort(key=lambda r: -r[3])
tab = build("sheets", "v4", credentials=creds, cache_discovery=False).spreadsheets().values()
tab.clear(spreadsheetId=SHEET_ID, range="Videos!A:G").execute()
tab.update(spreadsheetId=SHEET_ID, range="Videos!A1", valueInputOption="RAW", body={"values": [
["Title", "Published", "Duration", "Views", "Likes", "Comments", "Link"]] + rows}).execute()
return {"videos": len(rows)}FAQ
Common questions
Does it include Shorts and private videos?
Will it use up my YouTube API quota?
Can it keep weekly history per video?
What permissions does it need?
Does it need AI?
How many runs does it use?
Can I change how it works?
Related
You might also like
Upload Drive videos to YouTube at the time in your sheet
Videos you have put in Drive go up to YouTube at the date and time you set in a sheet, and the row is updated with the link.
See how it worksLog daily YouTube channel stats to Google Sheets
One row per channel per day records subscribers, total views and video count, with the change since the day before.
See how it worksPublish the next video from your sheet's queue
Each day the next ready video in your sheet is uploaded to YouTube with an AI-written title and description, and its row is marked published.
See how it worksKeep exploring
Set up “Export YouTube video stats to Google Sheets” from your assistant
Copy the prompt above, or connect your assistant first. Free plan, no credit card.