Below is a snippet of code that I tried.
<script src="https://apis.google.com/js/platform.js"></script>
<script type="text/javascript">
function onYtEvent(payload) {
if (payload.eventType == 'subscribe') {
alert("hello world")
});
} else if (payload.eventType == 'unsubscribe') {
alert("asdf");
}
if (window.console) {
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 I am facing is that it does not fire any event when the subscribe button is clicked . In the console, I see the following error:
Uncaught ReferenceError: __ytRIL is not defined
source
share