I embed the YouTube player on my site. Is there a way using JS or the YouTube API to know when a user has clicked on the video itself, which takes him to YouTube? I can’t find a good way to differentiate Flash clicks that play/stop the video vs. clicks that cause the user to go to YouTube.
Share
If you suscribe to the
onStateChangeevent then you can be notified when the player state changes.Then in the
onplayerStateChangeYou can check for a “5” value which is issued when the video is ready to be “played” for the first time or when the user clicks the video to open a new Youtube window. You should save the old value of the player state to distinguish the two cases.