Guides: How to Implement Mux Data

0:00

Hi, I'm Steve Hepernan co-founder and head of product here at Mux and I'm going

0:05

to walk you through your first Mux

0:07

integration. So let me set the stage first. What we're looking at here is a

0:11

very basic HTML page

0:14

We have our HTML tag title of my Mux integration and then a simple video tag

0:21

that has

0:22

controls turned on with an height and then also a source. If I go over to

0:27

Chrome and

0:29

load up this page in Chrome

0:31

You can see that the video plays back

0:33

It's Big Buck Bunny. Everybody's favorite or least favorite. So it's a very

0:38

simple example. This is what we're going to use to

0:41

show off our first integration

0:43

From here, let's go over to the Mux dashboard. On the Mux dashboard

0:48

we get our property list and from here we'll choose a property to integrate

0:54

with and

0:55

for this I'm going to choose our integration demo development property. So when

1:00

I click that

1:01

It brings up the SDK selection window. Now if you're using a specific video

1:07

player

1:08

you'll want to scan through this list to find that player and

1:11

use those docs to get set up. But for this example, all we need is the very

1:17

simple HTML video SDK.

1:19

So I'm going to click on that

1:23

So the first thing we're going to do is grab this line of JavaScript here. And

1:27

what this will do is

1:29

pull in the Mux JavaScript

1:33

into our HTML page. Now it's best practices to put at the end of the page

1:39

before the end of the body.

1:41

So I'm going to do that. I'm going to paste it right there.

1:43

Save the document and then go back to our docs.

1:50

This next note here is about installing with NPM. We're not building a

1:54

JavaScript application here using node.

1:56

So we can just blow right past that point.

2:00

To this example down here and what you'll see is something that should look

2:05

kind of familiar. In our example here

2:07

we have a very basic HTML video tag.

2:10

One difference is that our tag does not have this ID attribute yet.

2:17

So I'm going to go and copy the ID attribute from here and add it to

2:22

our video tag over here. And you'll see why that's important in a second.

2:28

I'll save that and go back to the docs.

2:31

And the next step would be copying this big block of JavaScript here.

2:37

What's happening in this JavaScript is we're essentially telling the Mux

2:42

JavaScript by using this Mux.monitor

2:46

function to start tracking our specific video tag here. So you can see that it

2:51

says my video

2:52

in this first argument of the Mux.Monitor function.

2:56

So that points to the ID of the video tag and it has the pound or hash symbol

3:03

before that,

3:03

which is basically CSS for pointing to that ID.

3:08

Under the scenes here we're using the document.querySelector API and so any CSS

3:14

value will work here

3:15

but you want to make sure that it's pointing to just the tag that you're

3:18

interested in tracking.

3:20

So I'll go ahead and copy this whole script tag.

3:24

And paste that into our example document here.

3:32

And it needs to come after the script that we pasted in the page before.

3:39

So that the Mux SDK is already in the page and then we can work with it after

3:44

that.

3:45

Now the next thing you want to make sure is that this property key is the

3:50

actual property API key

3:52

for the property you're trying to track. Now by nature of the way that we

3:57

clicked from a property

3:59

to the SDK selection into the docs Mux has already embedded this API key into

4:05

the docs for us.

4:06

But if you came to the docs directly you might see something here that is

4:10

example property key

4:11

and you want to replace that with the API key for the property you care about.

4:15

So I'll jump back to the Mux docs here, the Mux dashboard here really quick.

4:21

You can see the property that we're looking at is this integration demo

4:26

development

4:26

and the API key is right below that. And so we can just copy and paste that

4:32

into the same block. Now it's the same one for here but you'd be replacing the

4:37

example property key

4:38

otherwise. From here we can then start filling in additional details about the

4:43

video that playing

4:45

or the player specifically probably want to add a video title. That's a good

4:51

one to add.

4:51

So this is Big Buck Bunny so add that in. I mean you can work through these

4:59

different

5:00

metadata details. If you go to the docs and check out the options and metadata

5:08

section

5:09

you'll see all the different options that you have for providing additional

5:13

information to send

5:14

a Mux about the video that's playing or the page or the player which will give

5:20

Mux a little bit

5:20

more opportunity to provide interesting details in the dashboard and start to

5:25

correlate some of

5:26

these things together. Okay so once we have that all set up we can save this

5:33

document and then go

5:34

over to our example page and reload the page. The next thing I'm going to do is

5:40

actually open the

5:41

Chrome dev tools. So I'll go to more tools here and then dev tools. What that's

5:46

going to allow

5:47

us to do is just verify that the integration is working and beacons are being

5:52

sent to the Mux

5:54

backend. So when I'm on the network tab here I can then click play on the video

6:01

and the video

6:03

starts playing and you can start to see some details come through in the

6:07

network tab and what's

6:08

happening here is Mux is keeping track of the different events that are

6:12

happening as the video

6:13

plays and sending those to the Mux dashboard in order to track them and start

6:18

creating interesting

6:20

stats and details about the video that's playing. Great so just by the fact

6:25

that these beacons

6:26

are being sent we know that our integration is working. The next thing that you

6:30

can do in order

6:32

just kind of make this first integration process a little more interesting is

6:36

start by just reloading

6:38

this page and what that does is signal to Mux that the previous session of

6:44

watching the video is

6:46

now done. The page is reloaded and Mux can now take that whole video viewing

6:51

session and wrap it up

6:54

and start showing it in the dashboard. So by reloading we allow Mux to do that.

6:58

We can do that a few

6:59

more times skipping around in the video to create some interesting video view

7:06

details. You can even

7:08

play around Chrome has some nifty tools for throttling the video if you want to

7:13

try and cause

7:14

some rebuffering and see what that looks like in the dashboard but just reload

7:18

ing a few times will

7:19

give you a few different video views to look at and kind of see some start to

7:22

see some some graphs

7:24

show up. You'll you'll start to see data in the dashboard in about a minute or

7:29

two. It takes about

7:31

a minute for for Mux to determine that the video is finished roll up the

7:35

details and start showing

7:37

in the dashboard. But once you do that you can go back to the Mux dashboard and

7:42

you should see that

7:43

your property no longer has the add first integration flag at the top which

7:48

means that there's now

7:50

data in your account and you can click into the property and start seeing your

7:54

data. So great we've

7:56

finished with the first integration. If you have any problems or questions in

8:00

this process please

8:01

feel free to reach out. But otherwise thanks for watching!