Youtube with Analytics events

Asked

Viewed 84 times

1

I’m using the following scheme to embed Youtube videos: https://jsfiddle.net/4qcr60xz/

This allows the video to be requested only when the user clicks on the "player" (thumbnail), making the page load faster.

I need to add a Google Analytics event tracking for when the user clicks on the "play/thumbnail" that renders the video iframe.

ga('send', 'event', 'Videos', 'play', 'Video1');

There is a way to implement this to this jsfiddle code?

  • We do not use "Solved" here Diego. If an answer resolves your question mark it as correct. Learn more by doing the [tour]. :)

1 answer

0

SOLUTION:

document.querySelector(".youtube-player").addEventListener("click",function(){
ga('send', 'event', 'Videos', 'Play', 'Video1');
});

Browser other questions tagged

You are not signed in. Login or sign up in order to post.