I was building an analytics dashboard today that collected data from various services including Google Anaytics and YouTube. Apps Script makes this very easy as highlighted in my previous post. An issue I encountered when I tried to access our YouTube channel reports is even though my account is attached to as a manager I was getting a ‘Forbidden’ error. Turning to the Channel Reports documentation I discovered:
channel==CHANNEL_ID – Set
CHANNEL_ID to the unique channel ID of the channel for which you are retrieving data. The user authorizing the request must be the owner of the channel.
As our YouTube channel is associated with our Google+ page you can’t log in to Google Drive with that account. I did notice however that when I added YouTube Analytics as an Advanced Apps Script service the authentication prompt gave an option of authenticating using our Google+ page.
The issue then is if you authenticate against the Google+ page you can’t get access to other services like Google Analytics. I thought of a couple of ways I might tackle this such as writing a separate Apps Script project that just got the YouTube Analytics data and wrote it to the spreadsheet I was working on. I’m not entirely sure how the permissions would work out on that. Instead my solution was to expose the YouTubeAnalytics.Reports.query in a separate Apps Script published as a web app. Setting this to run ‘anyone, even anonymously’ I could then use UrlFetchApp to get the data in my main script.
Here’s how I set it up. Below (or in this gist) the 'main' script is handling all the data read/write to sheet and a separate 'proxy' Apps Script project running the YouTube Analytics data collection.
Note: This technique exposes our YouTube Channel report to the world (barring security by obscurity). The method we are exposing is read only so we don’t have to worry about an injection.
Feels a bit hacky but can you see a better way of doing this?
Update 22/07/2014: Matias Molinas had the great suggestion of writing the results to a sheet which would avoid exposing your data. Jarom McDonald has also suggested using Google App Engine would give security and scalability à la superProxy
The 2013 New Year’s greetings, from the French advertising and public relations company Publicis Groupe by their CEO Maurice Lévy is making multiple appearances in my circles
When I saw it my immediate thought was how did they do it? In the official press release they say:
It’s just one of the many very human interpretations of the standard YouTube functionality taken for granted today.
Looking for YouTube player functionality left me scratching my head. Looking at the source gave a big clue:
… basically the entire video area including title and controls is an embedded iframe. This allows Publicis Groupe to create their own Flash based player with custom functionality for pause, play etc.
To get the iframe into their YouTube channel they used YouTube’s Custom tab settings which are available on Branded Channels.
Simple but very effective.
Via Doug Holton I spotted that there is a new YouTube beta feature to add multiple choice questions (MCQ) to your Youtube videos. Those who have already taken a course on Coursera (surely everyone has now ;), will know the video with MCQ is one of the staples. From the ‘Video Questions Editor Beta’ page it says:
This is an opt-in beta for a simple Video Questions Editor on YouTube. Through this editor you can setup multiple questions to be displayed on top of your video during playback that a viewer can answer.
How can I use this feature?
The editor itself can be found on the video edit page, on the edit bar. After you have added several questions and the users have viewed them, you can see a summary of the interaction your users had with them through the analytics page, within the Annotations section.
The feature represents work in progress, there is no plan for long-term support of the feature and may be removed at any time without prior notification. Your comments will help us improve and perfect the mixtures we're working on. So jump in, play around and send your feedback directly to the brains behind the scenes.
The page also includes a link to opt-in to the beta.
If you do when you go to edit one of your videos you’ll get a ‘Questions’ button
Clicking on this lets you enter your question:
Unfortunately when I click on save it hangs on ‘Your changes are being saved...’.
It’s a shame that this feature doesn’t work yet. It’s interesting to put this development into the context of Google’s recent open source release of Course Builder, which was used as the technology behind their Power Searching with Google online course (xMOOC). So is Google trying to rock the boat in the mass online education market?