YouTube Analytics
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Buat laporan untuk saluran
function runYoutubeAnalyticsReport() {
// Get the list of all channels.
var myChannels = YouTube.Channels.list('id', {mine: true});
// Pick the first available channel.
var channel = myChannels.items[0];
var channelId = channel.id;
// Set the dates for report.
var today = new Date();
var oneMonthAgo = new Date();
oneMonthAgo.setMonth(today.getMonth() - 1);
var todayFormatted = Utilities.formatDate(today, 'UTC', 'yyyy-MM-dd');
var oneMonthAgoFormatted = Utilities.formatDate(oneMonthAgo, 'UTC',
'yyyy-MM-dd');
// See https://developers.google.com/youtube/analytics/v1/reports for
// supported dimensions and metrics.
var analyticsResponse = YouTubeAnalytics.Reports.query(
'channel==' + channelId,
oneMonthAgoFormatted,
todayFormatted,
'views,likes,dislikes,shares',
{
dimensions: 'day',
sort: '-day'
});
console.log(analyticsResponse);
}
Kecuali dinyatakan lain, konten di halaman ini dilisensikan berdasarkan Lisensi Creative Commons Attribution 4.0, sedangkan contoh kode dilisensikan berdasarkan Lisensi Apache 2.0. Untuk mengetahui informasi selengkapnya, lihat Kebijakan Situs Google Developers. Java adalah merek dagang terdaftar dari Oracle dan/atau afiliasinya.
Terakhir diperbarui pada 2024-08-21 UTC.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Informasi yang saya butuhkan tidak ada","missingTheInformationINeed","thumb-down"],["Terlalu rumit/langkahnya terlalu banyak","tooComplicatedTooManySteps","thumb-down"],["Sudah usang","outOfDate","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Masalah kode / contoh","samplesCodeIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2024-08-21 UTC."],[[["This script utilizes the YouTube Data API to generate a report for your YouTube channel."],["It retrieves data from the past month, including daily views, likes, dislikes, and shares."],["The report focuses on the performance of a single channel, prioritizing the first one found in your account if you have multiple."],["Data is formatted for logging to the console, providing a raw overview of your channel's recent activity."]]],[]]