Simple Use Cases
The following samples are suitable for simple use cases, where the browser page usually contains only a single video player, and the custom metadata are managed as a whole for the browser session.
Custom Metadata
Custom metadata can be set as a JavaScript plain object, such as the following.
datazoom.setMetadata({ key1: 1, key2: "default" });
The custom metadata will be persisted in the sessionStorage
, so it will remain valid until the browser tab is closed, or until it is cleared with the following call:
datazoom.setMetadata(null);
The current custom metadata (which was previously set or was restored from the storage) can be read back as in the following example:
var oldMetadata = datazoom.getMetadata(); // read back if (oldMetadata) { oldMetadata.pageCount ++; } datazoom.setMetadata(oldMetadata || { pageCount: 1 }); // set the updated metadata
Generate Custom Event
To generate a Datazoom event with a custom name, call the following function with the custom name (which will be prefixed with “Custom_“
datazoom.generateEvent("ButtonClick");
An optional argument can be included in the same function to add additional metadata (for the event generated by the specific call only) to the event message:
datazoom.generateEvent("ButtonClick", { buttonName: "xyz" });
By default, if available, the playback related data points (such as the metrics of the current view) from the first player on the page will be included in the custom event message generated.
If the extra metadata specified with the generateEvent()
call has duplicated keys as in the existing metadata previously set, the value from the extra metadata will take precedence of the existing one. However, since the extra metadata is only effective to the specific call where it is specified, the existing metadata’s value of the same key will not be affected in other places.
Custom Metadata Reserved Names
Some data values that are key to functionality or reporting on your analytic systems have been designated as Reserved Names
so that these values can be handled properly within the context of the receiving Connector.
Current List of Reserved Names
Reserved Name | Description |
---|---|
amplitudeSessionId | session identifier exposed by the Amplitude plugin on the page. |
googleAnalyticsClientId | unique user identifier set by the GA SDK. Application should retrieve this value from the installed GA SDK. |
mixpanelDistinctId | unique user identifier set by the Mixpanel SDK. Application should retrieve this value from the installed Mixpanel SDK. |
userId | unique internal user identifier set by the customer's identity management system. |
genre | Genre classification of the content |
Usage Example
Use custom method :
setDatazoomMetadata()
Single value example function call:
setDatazoomMetadata("googleAnalyticsClientId","XXXX");
Connector Effect
When a Reserved Name is properly set using Custom Metadata, it will be correctly placed within designated fields within the relevant Connector. For all other Connectors, these values will be treated like regular Custom Metadata and passed through if the Connector can support custom key value pairs.
Comments
0 comments
Article is closed for comments.