This guide demonstrates how to enable full analytics for embedded videos on your page.
To enable full analytics for a single embedded video, use the following code:
<!-- Movingimage iframe embedding -->
<iframe
style="border: none; width: 100%; aspect-ratio: 16/9;"
src="//e.video-cdn.net/watch?video-id=123&player-id=123&channel-id=123"
allowfullscreen
allow="autoplay; clipboard-write; encrypted-media; picture-in-picture; web-share;"
frameborder="0">
</iframe>
<script type="module">
import { Player } from 'https://e.video-cdn.net/mi-player-sdk/mi-player-sdk.js';
// Connect the SDK to the player
const player = new Player('mi-embedded-video');
// Set full analytics
player
.setAnalytics('full')
.then(() => {
console.log(`Full analytics enabled for video: ${player.getVideoId()}`);
})
.catch((error) => {
console.error(`Error enabling full analytics for video: ${player.getVideoId()}`, error);
});
</script>
If you have multiple video players embedded on your page, you can enable full analytics for all of them at once using the following approach:
<script type="module">
import { Player } from 'https://e.video-cdn.net/mi-player-sdk/mi-player-sdk.js';
// Get all players in the page
const players = Player.allPlayers();
// Enable full analytics for all players
Promise.all(
players.map((player) => player.setAnalytics('full'))
).catch((error) => {
console.error('Error setting full analytics', error);
});
</script>
Full Analytics can also be disabled, by requesting the player to use Minimal analytics instead (which is the default analytics mode).
This will prevent the player from further gathering any user identifiable information, while still recording the same analytics events:
<script type="module">
import { Player } from 'https://e.video-cdn.net/mi-player-sdk/mi-player-sdk.js';
// Connect the SDK to the player
const player = new Player('mi-embedded-video');
// Set minimal analytics
player
.setAnalytics('minimal')
.then(() => {
console.log(`Minimal analytics enabled for video: ${player.getVideoId()}`);
})
.catch((error) => {
console.error(`Error enabling minimal analytics for video: ${player.getVideoId()}`, error);
});
</script>