Back

Extension Set Up

Attached is a block of code that you can copy and paste into a JavaScript Code Extension. If you need help adding a JavaScript Code Extension see this post:

https://community.tealiumiq.com/posts/537843

Once pasted into the JavaScript code extension there are two configuration fields at the very top of the code that you can customize: video_events and milestone_percentages. 

  1. video_events - This is a list of events that you would like to track with the code. By default this is set up to track play, pause, complete and milestones, but you can simply add events to this like like "seek" to track when a user seeks within the video. A list of available events are found on Wistia's website here: http://wistia.com/doc/player-api#javascript_player_api_events
  2. milestone_percentages - This is a list of percentages that you would like to track as milestones. By default this is set to trigger an event when the video has reached 25, 50, 75 and 90 percent complete. However, this can be customized to your specific milestones. You can deactivate milestone tracking by removing the "secondchange" event from the video_events list. 
  3. video_element_id - Wistia requires the use of an element id to bind the video events to the video. You will receive a block of code from Wistia that will need to be added to your page code. Within this block of code will be the id that will be entered here.
    • If you are using the iframe embed method, which is recommended by Wistia, you will need to add an id to the block of code that Wistia gives you. 
  4. wistia_embed_type - The possible values here are "iframe" or "api." When you set up your video in the Wistia interface and you select "Embed and Share" from the Video Actions drop down, you are presented with three options of embeding: "iframe", "API" and "SEO." The API and SEO options use the same JavaScript Functions so we don't need to distinguish between those and for both of these options we can use "api" for the wistia_embed_type. But the iframe option requires a different method to "hook" into the video. This is why you will need to distinguish between "iframe" and "api." 

This code will wait until the Wistia Object has been defined then run through the necessary functions to attach the listeners. 

*** Though the code has logic to wait for the player to be defined, the JavaScript Code extension where you paste the code should be scoped to DOM Ready. ***

Output Variables

This code will output a set of data sources that you can add in the UI and then use to send data to your tag vendors. 

The variables are as follows:

  1. event_type - "video" This will always equal video for these events
  2. event_name - "play", "pause", "resume", "complete", "milestone" These are the default names that will be output. If you have customized the video_events variable as mentioned above then you may see something like volumechange for when a user changes the volume. 
  3. video_position - "11" This will output the position, in seconds, of the video when one of the events took place. i.e. pause or milestone
  4. video_duration - "119" This tells the over length of the video
  5. video_milestone - "M:1:25" This outputs the milestone number "1" and the milestone percentage "25." This allows you to see where your users are dropping out of the videos

Attached is a csv file with these variables and descriptions for easy uploading into the Data Sources tab of the Tealium UI. 

NOTE: This code will call utag.link, but there are lines that are commented out that will support the Media Module for SiteCatalyst. The thought behind calling utag.link is then you'll have another extension that will determine when to call the Media Module functions so this extension is more "plug and play" with less customizations.

Data Sources Upload Wistia Video Tracking Extension
Attachments