संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
YouTube Analytics सेवा की मदद से, Apps Script में YouTube Analytics API का इस्तेमाल किया जा सकता है. इस एपीआई की मदद से, उपयोगकर्ता YouTube वीडियो और चैनलों के लिए, वीडियो देखने से जुड़े आंकड़े, लोकप्रियता के मेट्रिक, और डेमोग्राफ़िक की जानकारी पा सकते हैं.
रेफ़रंस
इस सेवा के बारे में ज़्यादा जानने के लिए, YouTube Analytics API के रेफ़रंस दस्तावेज़ देखें. Apps Script की सभी ऐडवांस सेवाओं की तरह, YouTube Analytics सेवा भी सार्वजनिक एपीआई के ऑब्जेक्ट, तरीकों, और पैरामीटर का इस्तेमाल करती है. ज़्यादा जानकारी के लिए, तरीके के सिग्नेचर कैसे तय किए जाते हैं लेख पढ़ें.
नमूना कोड
यहां दिए गए सैंपल कोड में, YouTube Analytics API के वर्शन 2 के साथ-साथ YouTube Data API के वर्शन 3 का इस्तेमाल किया गया है. इसे Apps Script में YouTube सेवा के ज़रिए ऐक्सेस किया जा सकता है.
यह फ़ंक्शन, किसी चैनल के वीडियो के लिए एक स्प्रेडशीट बनाता है. इसमें हर दिन के व्यू की संख्या, देखने के कुल समय की मेट्रिक, और नए सदस्यों की संख्या शामिल होती है.
/** * Creates a spreadsheet containing daily view counts, watch-time metrics, * and new-subscriber counts for a channel's videos. */functioncreateReport(){// Retrieve info about the user's YouTube channel.constchannels=YouTube.Channels.list('id,contentDetails',{mine:true});constchannelId=channels.items[0].id;// Retrieve analytics report for the channel.constoneMonthInMillis=1000*60*60*24*30;consttoday=newDate();constlastMonth=newDate(today.getTime()-oneMonthInMillis);constmetrics=['views','estimatedMinutesWatched','averageViewDuration','subscribersGained'];constresult=YouTubeAnalytics.Reports.query({ids:'channel=='+channelId,startDate:formatDateString(lastMonth),endDate:formatDateString(today),metrics:metrics.join(','),dimensions:'day',sort:'day'});if(!result.rows){console.log('No rows returned.');return;}constspreadsheet=SpreadsheetApp.create('YouTube Analytics Report');constsheet=spreadsheet.getActiveSheet();// Append the headers.constheaders=result.columnHeaders.map((columnHeader)=>{returnformatColumnName(columnHeader.name);});sheet.appendRow(headers);// Append the results.sheet.getRange(2,1,result.rows.length,headers.length).setValues(result.rows);console.log('Report spreadsheet created: %s',spreadsheet.getUrl());}/** * Converts a Date object into a YYYY-MM-DD string. * @param {Date} date The date to convert to a string. * @return {string} The formatted date. */functionformatDateString(date){returnUtilities.formatDate(date,Session.getScriptTimeZone(),'yyyy-MM-dd');}/** * Formats a column name into a more human-friendly name. * @param {string} columnName The unprocessed name of the column. * @return {string} The formatted column name. * @example "averageViewPercentage" becomes "Average View Percentage". */functionformatColumnName(columnName){letname=columnName.replace(/([a-z])([A-Z])/g,'$1 $2');name=name.slice(0,1).toUpperCase()+name.slice(1);returnname;}
[[["समझने में आसान है","easyToUnderstand","thumb-up"],["मेरी समस्या हल हो गई","solvedMyProblem","thumb-up"],["अन्य","otherUp","thumb-up"]],[["वह जानकारी मौजूद नहीं है जो मुझे चाहिए","missingTheInformationINeed","thumb-down"],["बहुत मुश्किल है / बहुत सारे चरण हैं","tooComplicatedTooManySteps","thumb-down"],["पुराना","outOfDate","thumb-down"],["अनुवाद से जुड़ी समस्या","translationIssue","thumb-down"],["सैंपल / कोड से जुड़ी समस्या","samplesCodeIssue","thumb-down"],["अन्य","otherDown","thumb-down"]],["आखिरी बार 2025-08-04 (UTC) को अपडेट किया गया."],[[["The YouTube Analytics API allows you to access viewing statistics, popularity metrics, and demographic data for YouTube videos and channels within Apps Script."],["This is an advanced service that requires enabling before use."],["The provided sample code demonstrates how to create a spreadsheet report containing daily view counts, watch time, and subscriber data for a YouTube channel using the API."],["The API utilizes the same objects, methods, and parameters as the public YouTube Analytics API, ensuring consistency and familiarity for developers."],["For further support and issue reporting, refer to the YouTube API support guide."]]],[]]