Skip to content

Commit f79f2d2

Browse files
author
Eric Koleda
committed
Update sample to be compatible with v2 of the API.
1 parent afa0953 commit f79f2d2

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

advanced/youtubeAnalytics.gs

+6-8
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,16 @@ function createReport() {
3434
'views',
3535
'estimatedMinutesWatched',
3636
'averageViewDuration',
37-
'averageViewPercentage',
3837
'subscribersGained'
3938
];
40-
var options = {
39+
var result = YouTubeAnalytics.Reports.query({
40+
ids: 'channel==' + channelId,
41+
startDate: formatDateString(lastMonth),
42+
endDate: formatDateString(today),
43+
metrics: metrics.join(','),
4144
dimensions: 'day',
4245
sort: 'day'
43-
};
44-
var result = YouTubeAnalytics.Reports.query('channel==' + channelId,
45-
formatDateString(lastMonth),
46-
formatDateString(today),
47-
metrics.join(','),
48-
options);
46+
});
4947

5048
if (result.rows) {
5149
var spreadsheet = SpreadsheetApp.create('YouTube Analytics Report');

0 commit comments

Comments
 (0)