Optimize <video> elements for stats
Our real-time statistics feature offers a comprehensive picture of your site’s video traffic for all Paid plans.
You can access the individual statistics page for each of your sites via the “View Stats” button on this page.
By default, there is nothing to set up in order to start viewing your video statistics. However, if you think your <source /> elements might change in future or if you’d like to customize the name of the videos that are shown in your statistics page, you should read the following sections.
The data-uid attribute
If your video doesn’t have a data-uid and you modify its first <source />’s src attribute, the video will appear as a new video on your statistics page (we use the first <source /> to track a video).
To avoid this, you can set a unique id to your <video> element by adding a data-uid attribute to it. Your video will then be identified by this unique id instead of by its first <source />. Here is an example:
<video class="sublime" poster="some-great-landscapes.jpg" data-uid="landscape1"> <source src="http://yoursite.com/some-great-landscapes.mp4" /> <source src="http://yoursite.com/some-great-landscapes.webm" /> </video>
Although this id can be any string, we recommend that you use small strings (between 4 and 20 characters, probably depending on the number of videos you have).
Note that if you plan to use video statistics extensively, we recommend that you always set the data-uid attribute to all of your <video> elements.
The data-name attribute
By default, we will generate a name based on the first <source />’s src value to display your video in the statistics page
For instance, if you have a video element like the following:
<video class="sublime" poster="some-great-landscapes.jpg"> <source src="http://yoursite.com/some-great-landscapes.mp4" /> <source src="http://yoursite.com/some-great-landscapes.webm" /> </video>
Your video will appear (along with a small thumbnail of its poster frame) with the name “Some great landscapes”.
However if you’d like to customize the title that appears in your statistics page, you can then add a data-name attribute to your <video>. The attribute content will replace the default title we use in your statistics page. Here is an example:
<video class="sublime" poster="some-great-landscapes.jpg" data-name="My great landscapes"> <source src="http://yoursite.com/some-great-landscapes.mp4" /> <source src="http://yoursite.com/some-great-landscapes.webm" /> </video>
Note: You can update the data-name as often as you’d like. Such changes will be reflected in the statistics page in near real-time.