Dynamic Metadata
Published: 2020-10-21 18:16:25

---
title: Dynamic Metadata
published: true
date: 2020-10-13 00:00:00 UTC
tags: 
canonical_url: https://api.video/blog/tutorials/dynamic-metadata
---

Organisation of your videos helps you deliver the correct videos to the correct page. We have previously written about how to [add tags](https://api.video/blog/tutorials/video-tagging-best-practices) to your videos in order to better categorise them, and then use the tags for video delivery. If you look closely in our API, we also offer a metadata tag with key:value pairs to be used as an additional organisational tool. In many ways, metadata and tags are functionally similar. However, we also support the concept of Dynamic metadata. Dynamic metadata is not directly related to the video - but is more related to how the video has been consumed. The values of dynamic metadata are variable and are added during playback - allowing you to further segment your audience analytics. 

## Analytics 

By default the api.video analytics engine can report both [video stats]() and [session specific]() data. There is a [tutorial](https://api.video/blog/tutorials/video-analytics-a-primer) describing how to use the analytics endpoints. 

Stats: Each video can be parsed to quantify views, time/date of view, browser and location, and more. You can read more on the [Video Analytics](https://docs.api.video/reference#get\_analytics-videos-videoid) endpoint. [

Session](https://docs.api.video/reference#get\_analytics-sessions-sessionid-events): Each video session has a unique ID. For each session, several events are recorded in the player. Currently, this list is: ```ready, play, pause, resume, seek.backward, seek.forward, end```. 

By default, you gain a lot of insight as to how your audience view and consume your video. We can use dynamic metadata to segment your audiences for deeper insights. 

## Segmenting your video audience 

Imagine that you have 2 segments of users on your website: dog lovers and cat lovers. You want to know which videos are more appreciated by each segment of your population. For these videos you can add a dynamic metadata key:value where the value changes depending on the viewer. For example: ``` [{"key" : "dogcat", "value", " __dogcat__"}] ``` The double underscore before and after the value tells the API that this is a dynamic attribute, and the value of the dogcat attribute will be measured on each session of the video. 

## Using the segmentation 

Now that you have added the dog/cat segmentation to the video, each view of the video can be segmented. To do this, we append a url parameter. For example, dog lovers would receive this video: 

(there are not embed options on dev.to)
https://embed.api.video/vod/vi2WbMm8rUWIQSzMS53aculW?metadata[dogcat]=dog

and cat lovers would receive this video: 


https://embed.api.video/vod/vi2WbMm8rUWIQSzMS53aculW?metadata[dogcat]=cat

he video is my dog Malla, who is named after Chewbacca’s wife (from the infamous Star Wars Holiday Special). You have to admit, she sounds a bit like a Wookie. These urls can be built dynamically based on user profiles on the website. When the video is watched, this metadata is added to the analytics session. Each video play will mark the viewer as either a dog lover or a cat lover. Now, since the viewer's cat/dog preference is added to the video statistics, you can learn how your two audiences interact with each video on your site, and which videos are preferred by dog or cat people. 

Using the video stats endpoint, I have found that my team is: \* 50% dog 
\* 37.5% cat 
and, well: 
\* 12.5% smartass: 
``` "key": "dogcat", "value": "dog" "key": "dogcat", "value": "dog" "key": "dogcat", "value": "cat" "key": "dogcat", "value": "cat" "key": "dogcat", "value": "dog" "key": "dogcat", "value": "cat" "key": "dogcat", "value": "dog" "key":"dogcat", "value":"rhinoceros" ``` 

If you have unique ids for each user, you could also track video watching per user (how often they view each video, or if they are watching the entire video). This could be very useful for online training compliance, classes, or even to check on credential sharing. The possibilities are endless! 

### Conclusion 

Using dynamic metadata and url parameters, you can segment your video analytics in to different populations, and better understand how your users are using your videos. How are you using dynamic metadata in your app's videos? Leave a note in the [community forum](https://community.api.video).