You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
With the analytics.js YouTube Plugin, you can collect YouTube player events into the Segment ecosystem.
6
+
With the analytics.js YouTube Plugin you can collect YouTube player events into the Segment ecosystem.
7
7
8
8
The Segment YouTube Plugin uses the following Google APIs:
9
9
-[YouTube IFrame player API](https://developers.google.com/youtube/iframe_api_reference#Getting_Started){:target="_blank”}: Controls the video (play, pause, stop).
10
10
-[Data API](https://developers.google.com/youtube/v3/getting-started){:target="_blank”}: Accesses metadata about the video in the iFrame.
11
11
12
12
##Prerequisites
13
13
14
-
To begin, create a new project in the Google Developer Console, then create a new API key in that project. You can read more about this process in the YouTube documentation on[registering an application](https://developers.google.com/youtube/registering_an_application){:target="_blank”}.
14
+
To begin, create a new project in the Google Developer Console, then create a new API key in that project. You can read more about this process in the YouTube documentation on[registering an application](https://developers.google.com/youtube/registering_an_application){:target="_blank”}.
15
15
16
16
>warning "Secure your API keys"
17
-
>You can[secure your API keys](https://cloud.google.com/docs/authentication/api-keys#securing){:target="_blank”} by adding API key restrictions, deleting unused API keys, and periodically rotating your keys.
17
+
>You can[secure your API keys](https://cloud.google.com/docs/authentication/api-keys#securing){:target="_blank”} by adding API key restrictions, deleting unused API keys, and periodically rotating your keys.
18
18
19
-
##Gettingstarted
19
+
##GettingStarted
20
20
21
21
After you've generated the API key:
22
22
23
23
1. Enable a new plugin.
24
24
25
-
- Navigate to**Connections > Sources** and choose the source you want to connect the YouTube plugin to. Go to the**Settings** tab of your source and select**Plugins**. You can enable the YouTube plugin from this menu:
25
+
- Navigate to**Connections > Sources** and choose the source you want to connect the YouTube plugin to. Go to the**Settings** tab of your source and select**Plugins**. You can enable the YouTube plugin from this menu:
**Note:** Only JavaScript sources support plugins.
29
+
**Note:** Only JavaScript sources support plugins.
30
30
31
31
2. Initialize the plugin by giving it access to the YouTube video player instance(s) running on your page. This can be done by adding the following script to the section of the source code where the page loads.
32
32
33
-
- Use the initialize method in the YouTube`onYouTubeIframeAPIReady()` function to register and initialize the plugin with the player instance and your API key:
33
+
- Use the initialize method in the YouTube`onYouTubeIframeAPIReady()` function to register and initialize the plugin with the player instance and your API key:
34
34
35
35
```js
36
36
var player;
@@ -48,7 +48,7 @@ var player;
48
48
49
49
The plugin listens to the YouTube player for events, and fires the corresponding[Segment Video Spec](/docs/connections/spec/video/) events on analytics.js.
50
50
51
-
##Supportedevents
51
+
##SupportedEvents
52
52
The plugin tracks the following[Segment Video Spec](/docs/connections/spec/video/) events:
53
53
54
54
Event | Details
@@ -60,17 +60,17 @@ Video Playback Buffer Started/Completed | When playback starts and finishes buff
60
60
Video Playback Seek Started/Completed | When a user manually seeks a certain position of the content or ad in the playback.
61
61
Video Content Started/Completed | When a video content segment starts and completes playing within a playback. <br><br>- If playing a playlist, these events get fired for each individual video.
62
62
63
-
##Supportedproperties
64
-
The plugin automatically attaches the following[Segment Video Spec](/docs/connections/spec/video/) to[supportedevents](#supported-events):
63
+
##SupportedProperties
64
+
The plugin automatically attaches the following[Segment Video Spec](/docs/connections/spec/video/) tothe aboveevents: