Reputation: 116
Below is the snippet of the code which I have tried:
<script src="https://apis.google.com/js/platform.js"></script>
<script type="text/javascript">
function onYtEvent(payload) {
if (payload.eventType == 'subscribe') {
// Add code to handle subscribe event.
alert("hello world")
});
} else if (payload.eventType == 'unsubscribe') {
// Add code to handle unsubscribe event.
alert("asdf");
}
if (window.console) { // for debugging only
window.console.log('YT event: ', payload);
}
}
</script>
<div class="g-ytsubscribe" data-channelid="UCGsSHWM4ZraLZ8k6m4q4g-A" data-layout="default" data-count="hidden" data-onytevent="onYtEvent"></div>
The problem that I am facing is that it is not firing any event on clicking the subscribe button. In the console, I can see the following error-
Uncaught ReferenceError: __ytRIL is not defined
Upvotes: 4
Views: 1613
Reputation: 24785
Here is a Google bug tacking this issue: https://code.google.com/p/gdata-issues/issues/detail?id=8569
Please Star the bug so that it gets their attention.
It even happens on Google's own site: https://developers.google.com/youtube/youtube_subscribe_button
Upvotes: 2