-
Notifications
You must be signed in to change notification settings - Fork 4
/
exemplo.html
35 lines (33 loc) · 1.21 KB
/
exemplo.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<!--
Este script manipula o player do youtube e envia ao mautic os plays e tambem
informa se o lead assistiu o video até o fim
para utilizar basta trocar o ID do vídeo no iframe abaixo: (Exemplo: NpEaa2P7qZI)
e depois inserir o endereço do seu mautic na variável mauticUrl.
-->
<iframe id="player" height="500px" src="https://www.youtube.com/embed/NpEaa2P7qZI?enablejsapi=1"></iframe>
<script>
var player;
// coloque aqui o URL do seu Mautic
var mauticUrl = "https://mkt.teste.com";
function onYouTubeIframeAPIReady() {
player = new YT.Player('player', {
events: {
'onStateChange': onPlayerStateChange
}
});
}
function onPlayerStateChange(event) {
var videoUrl = event.target.getVideoUrl();
var videoTitle = player.getVideoData()['title'];
var videoid = player.getVideoData()['video_id'];
var video_tag = 'youtube_' + videoid;
switch (event.data) {
case 1:
tracking = new Image();
tracking.src = mauticUrl + '/mtracking.gif?tags=' + video_tag + '&page_url=' + videoUrl + '&page_title=' + videoTitle;;
document.body.appendChild(tracking);
break;
}
}
</script>
<script src="https://www.youtube.com/iframe_api"></script>