Hi All,
We have Wistia video embedded on page without Iframe. Has anyone done Wistia video milestone tracking through Adobe Launch?
Solved! Go to Solution.
Views
Replies
Total Likes
You'll probably have to leverage the Wistia JS API to monitor video activity. In the past, when taking a similar approach, I've loaded the related JS in a page load rule (only on pages where videos exist), then triggered a direct call rule from within the JS. Passing a payload in with the direct call rule lets me specify the milestone to track (play, 25%, 50%, 75%, complete, etc), as well as any other meta data I might need (video title, ID, duration, etc).
window.videos = {};
wistiaEmbeds.forEach(function (vid) {
window.videos[vid.hashedId()] = {
id: vid.hashedId(),
name: vid.name(),
duration: vid.duration(),
status: {
step_play: false,
step_25: false,
step_50: false,
step_75: false,
step_95: false,
step_end: false
}
}
function trackProgress(milestone, currentVideo) {
currentVideo.milestone = milestone;
console.log("Video milestone", milestone, "reached for:", currentVideo);
// trigger your direct call rule here
// _satellite.track("dcr:video progress", currentVideo);
}
function checkProgress(milestone, percent) {
var step = "step_" + milestone;
if (milestone === "play" || milestone === "end") {
if (!window.videos[vid.hashedId()].status[step]) {
window.videos[vid.hashedId()].status[step] = true;
trackProgress(step, window.videos[vid.hashedId()]);
}
} else {
if ((percent * 100) >= milestone) {
if (!window.videos[vid.hashedId()].status[step]) {
window.videos[vid.hashedId()].status[step] = true;
trackProgress(step, window.videos[vid.hashedId()]);
}
}
}
}
vid.bind('percentwatchedchanged', function (percent, lastPercent) {
checkProgress(25, percent);
checkProgress(50, percent);
checkProgress(75, percent);
checkProgress(95, percent);
});
vid.bind('play', function() {
checkProgress('play');
});
vid.bind('end', function() {
checkProgress('end');
});
});
Caveats and assumptions:
You'll probably have to leverage the Wistia JS API to monitor video activity. In the past, when taking a similar approach, I've loaded the related JS in a page load rule (only on pages where videos exist), then triggered a direct call rule from within the JS. Passing a payload in with the direct call rule lets me specify the milestone to track (play, 25%, 50%, 75%, complete, etc), as well as any other meta data I might need (video title, ID, duration, etc).
window.videos = {};
wistiaEmbeds.forEach(function (vid) {
window.videos[vid.hashedId()] = {
id: vid.hashedId(),
name: vid.name(),
duration: vid.duration(),
status: {
step_play: false,
step_25: false,
step_50: false,
step_75: false,
step_95: false,
step_end: false
}
}
function trackProgress(milestone, currentVideo) {
currentVideo.milestone = milestone;
console.log("Video milestone", milestone, "reached for:", currentVideo);
// trigger your direct call rule here
// _satellite.track("dcr:video progress", currentVideo);
}
function checkProgress(milestone, percent) {
var step = "step_" + milestone;
if (milestone === "play" || milestone === "end") {
if (!window.videos[vid.hashedId()].status[step]) {
window.videos[vid.hashedId()].status[step] = true;
trackProgress(step, window.videos[vid.hashedId()]);
}
} else {
if ((percent * 100) >= milestone) {
if (!window.videos[vid.hashedId()].status[step]) {
window.videos[vid.hashedId()].status[step] = true;
trackProgress(step, window.videos[vid.hashedId()]);
}
}
}
}
vid.bind('percentwatchedchanged', function (percent, lastPercent) {
checkProgress(25, percent);
checkProgress(50, percent);
checkProgress(75, percent);
checkProgress(95, percent);
});
vid.bind('play', function() {
checkProgress('play');
});
vid.bind('end', function() {
checkProgress('end');
});
});
Caveats and assumptions:
How do I track milestones for wistia video in an iframe?
Views
Replies
Total Likes
@AAanon - It's actually pretty similar. Using the documentation on the Wistia site, there's a quick reference to interacting with videos that are embedded via IFRAME.
Assuming you have the necessary Wistia JS library on the page (
Views
Replies
Total Likes
Can you help me with passing the payload in with the direct call? I created direct call rules each to track start, 25%, 50%, 75%, and end, but not sure out to capture that in the custom code so it sends the data to analytics. An example would be useful
Views
Replies
Total Likes
@AAanon - No problem.
I would suggest a single direct call rule to handle all of your video tracking. For this sake of this post, let's assume this rule is named "dcr:video progress" and that we're doing the following two things:
Setting Adobe Analytics variables
In the video tracking library I shared in my earlier comments, uncomment the _satellite() call on line 17. This should set you up to call the "dcr:video progress" direct call rule, passing in a payload (JS object) with the following properties:
Add an Adobe Analytics Set Variables action to the rule. When setting variables other than events, you can reference the properties from the payload directly using the %event.detail.property% syntax. For example. Note that for eVar4, I'm concatenating multiple values:
To set any events, update using custom code similar to the example below. Note the use of s.linkTrackVars and s.linkTrackEvents because we're sending this using an s.tl() request:
Sending the Analytics beacon with a link tracking (s.tl()) call
Nothing special here. Set up an Adobe Analytics Send Beacon action and you're in buisiness. Feel free to give the custom link a static name (the direct call rule name, perhaps), or even make it dynamic using the %event.detail.property% syntax highlighted above.
The example call below is from a "step_play" tracking call and is based on the eVar and event settings above.
Views
Replies
Total Likes