Javascript SDK attributes

TABLE OF CONTENTS



Embed parameters can be added to the <div id="PLAYER_ID"></div>element to customize it or to add behavior. The supported parameters are listed below.
Parameter
Required
Type
Description
id
Required
String
A unique player id, have to be the same as element id attribute.
subid-function
Optional
String
A javascript function name, defined on the global scope. The return value of this function will be available as a custom dimension for Video Channels reporting.
onimpression
Optional
String
A javascript function name, defined on the global scope. This function will be called each time there is an ad-impression and will be passed an object as a parameter.
data-exs-config
Optional
String
An external config to pass in. This string should be in JSON string format and should be parsable.

SubID Function Example


Step 1: Create a global function declared on the window that returns the subid value. This value will be available as a custom dimension in the Video Channels reporting.


<script>
  window.getSubId = function() {
      return 'custom-dimension';
  };
</script>
Step 2: Follow the instructions of embedding the player using the embed-code snippet. Then add to the player element an attribute called subid-function with the value of the name of your global function.
<script>
(function (d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s);
  js.id = id;
  js.src = "https://player.ex.co/player/PLAYER_ID";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'JS-ID'));
</script>
<div id="PLAYER_ID" subid-function="getSubId"></div>

Impression Callback


Step 1: Create a global function declared on the window that will be called each time there is an ad-impression
<script>
  window.getAdImpression = function(impression) {
      console.log(`Ad impression occurred`);
  };
</script>
Step 2: Follow the instructions of embedding the player using the embed-code snippet. Then add to the player element an attribute called onimpression with the value of the name of your global function.
<script>
(function (d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s);
  js.id = id;
  js.src = "https://player.ex.co/player/PLAYER_ID";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'JS-ID'));
</script>
<div id="PLAYER_ID" onimpression="getAdImpression"></div>

External Configuration Example


Follow the instructions of embedding the player using the embed-code snippet. Then add to the player element an attribute called data-exs-config with a json format value

<script>
(function (d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s);
  js.id = id;
  js.src = "https://stream.playbuzz.com/embed/sdk.js?embedId=PLAYER_ID";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'JS-ID'));
</script>
<div id="PLAYER_ID" data-exs-config='{"key":"value"}'></div>


External Configuration Object

Key
Type
Description
videos
Object
See Videos section.
reporting
Object
See Reporting section.
cta
Object
See CTA section.
customParams
Object
See CustomParams section.

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons

Feedback sent

We appreciate your effort and will try to fix the article