I have an iOS app in which I play YouTube videos using the YouTube iframe API.
Inside YouTube, when looking in the analytics panel->Traffic sources I'm seeing the hits classified as "Other YouTube features"->"Unknown"
Is there a parameter I can pass that would identify the hits as coming from my app?
I can see that most apps playing YouTube videos are registered under "External" and then the name of the app (E.g. WhatsApp, embedly.com etc.)
I'm using the UIWebView to load an HTML that's using the YouTube iframe API like this:
<iframe id='playerId' type='text/html' width='100%%' height=100%%' src='https://www.youtube.com/embed/<videoId>enablejsapi=1&rel=0&playsinline=0&autoplay=1' frameborder='0'>
It's possible the the analytics are using the origin
parameter of the iFrame API.
You might be able to get analytics information by adding &origin=http://com.example.yourApp
or some other valid URL to your player parameters.
Autoplay seems to work for me like so:
<iframe id='playerId' type='text/html' width='100%%' height=100%%' src='https://www.youtube.com/embed/jCHE0Tjw6MA?enablejsapi=1&rel=0&playsinline=0&autoplay=1&origin=http://com.example.yourApp' frameborder='0'>
Swift implementation:
let webView = UIWebView(...)
webView.allowsInlineMediaPlayback = true
webView.mediaPlaybackRequiresUserAction = false
let videoID = "zN-GGeNPQEg"
let embededHTML = "<html><body style='margin:0px;padding:0px;'><script type='text/javascript' src='http://www.youtube.com/iframe_api'></script><script type='text/javascript'>function onYouTubeIframeAPIReady(){ytplayer=new YT.Player('playerId',{events:{onReady:onPlayerReady}})}function onPlayerReady(a){a.target.playVideo();}</script><iframe id='playerId' type='text/html' width='\(self.view.frame.size.width)' height='\(self.view.frame.size.height)' src='http://www.youtube.com/embed/\(videoID)?enablejsapi=1&rel=0&playsinline=1&autoplay=1&origin='http://com.example.myApp/'' frameborder='0'></body></html>"
webView.loadHTMLString(embededHTML, baseURL: nil)