Examples: Using tags

Examples: Using tags

1. Video playback events (play, pause, end)

HTML:

<video id="demo" width=720 height=300 controls>
<source src="video.mp4" type="video/mp4">
Video not supported by your browser.
</video>

JavaScript:

var v = document.querySelector('#hero-video');
// PAUSE
v.addEventListener('pause', function() {
UST.addTag('video_paused');
// You can also add another tag with the exact time at which the video was paused
UST.addTag('video_paused_at_' + Math.round(v.currentTime));
});
// PLAY
v.addEventListener('play', function() {
UST.addTag('video_play');
});
// ENDED
v.addEventListener('ended', function() {
UST.addTag('video_end');
});

Result:

Recorded users will then have tags similar to those:

2. Track if user scrolled on homepage

JavaScript:

// Add a tag for users who scroll at least once on the homepage
window.addEventListener('scroll', function didScroll() {
UST.addTag('scrolled_on_home');
window.removeEventListener('scroll', didScroll); // Sending it once is enough, remove listener
});

Result:

Recorded users will then have tags similar to this: