Answer the question
In order to leave comments, you need to log in
How to track Youtube subscribe button events?
I need to track clicks on the "Subscribe" button from Google. Here there is a "generator" of the button and the option "Tracking clicks" - https://developers.google.com/youtube/youtube_subs...
I get the following code:
<script src="https://apis.google.com/js/platform.js"></script>
<script>
function onYtEvent(payload) {
if (payload.eventType == 'subscribe') {
// Add code to handle subscribe event.
ga('send', 'event', 'button', 'click', 'nav-buttons');
} else if (payload.eventType == 'unsubscribe') {
// Add code to handle unsubscribe event.
}
if (window.console) { // for debugging only
window.console.log('YT event: ', payload);
}
}
</script>
<div class="g-ytsubscribe" data-channel="GoogleDevelopers" data-layout="default" data-count="default" data-onytevent="onYtEvent"></div>
Answer the question
In order to leave comments, you need to log in
I'm afraid that everything is bad:
https://code.google.com/p/gdata-issues/issues/deta...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question