Tracking Wistia Video Engagement with Usermaven
Overview
This guide explains how to track Wistia video interactions (play, progress, and completion) as custom events in Usermaven. It assumes you have Wistia videos embedded on your website and the Usermaven tracking script installed.
Using Wistia’s JavaScript Player API , you can capture video events and send them to Usermaven for detailed engagement analytics.
Step 1: Add Wistia Event Tracking
Add the following script to track events for all Wistia videos on a page. Place it after the Wistia and Usermaven tracking scripts in your HTML. The script binds to Wistia events (play
, percentwatchedchanged
, and end
) and sends them to Usermaven.
// Place this script after Wistia and Usermaven tracking scripts
_wq = _wq || [];
_wq.push({
id: "_all",
onReady: function (video) {
// Ensure usermaven is available
if (typeof usermaven !== "function") {
console.warn("Usermaven not loaded");
return;
}
// Track play
video.bind("play", function () {
usermaven("track", "wistia_video_play", {
video_id: video.hashedId(),
video_title: video.name()
});
});
// Track 50% milestone
let halfwaySent = false;
video.bind("percentwatchedchanged", function (percent, lastPercent) {
if (!halfwaySent && percent >= 0.5) {
halfwaySent = true;
usermaven("track", "wistia_video_50_percent", {
video_id: video.hashedId(),
video_title: video.name(),
percent_watched: percent
});
}
});
// Track completion
video.bind("end", function () {
usermaven("track", "wistia_video_complete", {
video_id: video.hashedId(),
video_title: video.name(),
duration_seconds: Math.round(video.duration())
});
});
}
});
Notes
- The
id: "_all"
selector applies tracking to all Wistia videos on the page. - Event properties (
video_id
,video_title
) help distinguish videos in Usermaven. - The
halfwaySent
flag prevents duplicate 50% milestone events. - The
percentwatchedchanged
event fires when the video’s watched percentage changes, passingpercent
(current percentage) andlastPercent
(previous percentage). - Use
usermaven("track", event_name, properties)
for custom events. - Ensure Wistia and Usermaven scripts load before this code to avoid errors.
Step 2: Track Specific Videos (Optional)
To apply different tracking logic to a specific video, replace id: "_all"
with the video’s unique ID (e.g., id: "abc123xyz"
). Find the ID in your Wistia dashboard or video embed code.
Step 3: Verify Tracking
- Interact with a video on your website (play, watch past 50%, or complete it).
- Check your Usermaven dashboard (Configure Events > Custom Events tab) for event names such as:
wistia_video_play
wistia_video_50_percent
wistia_video_complete