Setting up Media Analytics
Media Analytics in FirstHive CDP automatically tracks how visitors engage with your website’s video and audio content, including HTML5, YouTube, and Vimeo media across popular players like JW Player, VideoJS, and MediaElement.js.
Embedding the Media Analytics JavaScript Tracker
If you have already embedded the FirstHive CDP JavaScript Tracking Code into your website, Media Analytics will automatically start tracking the usage of video and audio. The video player tracking code is directly added in your FirstHive CDP JavaScript tracker file /firsthive.js as long as the file is writable by the webserver/PHP.
To check whether this works by default for you, log in to FirstHive CDP as a Super User, go to Administration, and open the “System Check” report. If the System Check displays a warning for Writable firsthive.js learn below how to solve this.
Tracking HTML5 Videos
Tracking of HTML5 video works automatically. However, you may not be tracking accurate titles for your videos by default. We recommend setting a data-firsthive-title attribute on your <video> elements:
<video data-firsthive-title=“My Video Title”>…</video>
This also works when using an HTML5-based video player like VideoJS.
Tracking HTML5 Audios
Tracking of HTML5 audio works automatically. We recommend setting a data-firsthive-title attribute on your <audio> elements:
<audio data-firsthive-title=“My Audio Title”>…</audio>
Tracking JW Player Videos
Tracking of JW Player works automatically. However, accurate titles may not be captured by default. Specify a title in the setup method of your video:
jwplayer(“myDiv”).setup({ “file”: ”…”, “title”: “My Video Title” });
Tracking Flowplayer Videos
Tracking of Flowplayer works automatically. If you use the JavaScript embed method, specify a title in the Flowplayer setup:
flowplayer(“#player”, { clip: { sources: [ {type: “video/mp4”, src: “https://example.org/actualUrl.mp4”} ], title: “My Video Title” } });
If embedding via the <video> element, set a title using data-firsthive-title, data-piwik-title, or the title attribute.
Note: Currently, only HTML5 videos for Flowplayer are supported. For Flash videos, contact support or consider using the hlsjs plugin to switch to HTML5.
Tracking Vimeo Videos
Vimeo videos are tracked automatically if embedded as an <iframe>.
Tracking SoundCloud Audio
SoundCloud audio is tracked automatically if embedded as an <iframe>.
Tracking YouTube Videos
Media Analytics uses the YouTube iFrame API. For tracking, enable the API by adding ?enablejsapi=1 to your video URLs:
<iframe src=“https://www.youtube.com/embed/yA2NUur0770?enablejsapi=1”></iframe>
Without enablejsapi=1, events from the YouTube player may not be received.
Loading Additional YouTube Files
The tracker loads https://www.youtube.com/iframe_api to receive events. To disable YouTube tracking, use:
_paq.push([‘MediaAnalytics::removePlayer’, ‘youtube’]);
Using YouTube IFrame API Already on Your Site
If your site already uses the YouTube IFrame API and the onYouTubeIframeAPIReady callback, notify the media tracker when the API is ready:
window.onYouTubeIframeAPIReady = function () { // […] your code _paq.push([‘MediaAnalytics::scanForMedia’]); };
The tracker does not overwrite your existing onYouTubeIframeAPIReady method.
When firsthive.js Is Not Writable
If Settings > **System Check **reports that firsthive.js is not writable:
- Make the file writable (e.g., chmod a+w firsthive.js or chown $phpuser firsthive.js) and run the FirstHive CDP console command to update:./console custom-firsthive-js:update
- Or manually load the Media Analytics tracker on all pages:<script src=“https://your-firsthive-domain/plugins/MediaAnalytics/tracker.min.js”></script>
Disadvantages of Manual Inclusion
- Adds an extra HTTP request, slightly increasing page load time.
- If firsthive.js becomes writable later, the tracker may load twice (the tracker detects this and prevents duplicate tracking).
We recommend making firsthive.js writable whenever possible.