Widgets

Here you find all US widgets groups. When you find your widget, be sure to enter correct widget name in addWidget function. That name is the one in bold below the widget.

Let's take an example. If you take a look at us.match.score widget, you'll see the big name Widgets.us.match.score, but name of a widget, expected in addWidget function is actually us.match.score.

Namespaces

us

Methods


<static> onTrack(param1, param2)

Use onTrack function as a prop to every widget. This function will be invoked whenever any of specified events occurs:

  1. data_change - whenever widget gets new data as a response to (external) prop change. If new data results in an error, the error property will be set.
  2. odds_click - user clicks on an odds button.
  3. social_share - user clicks on social share button,
  4. license_error - widget returns a licensing error.

Function emits two parameters containing triggered event (param1) and object with relevant data (param2).

Parameters
Name Type Description
param1 string

Type of triggered event, contains one of the following strings:

  • data_change,
  • odds_click,
  • social_share,
  • license_error.

param2 object

Relevant data, object, contains data depending on the event type:

  • {'scheme', 'solution', 'component', 'version', 'language', 'channel', 'customer', 'brand', 'scope', 'sportId', 'categoryId', 'uniqueTournamentId', 'tournamentId','seasonId', 'matchId', 'team1uid', 'team2uid', 'player1id', 'continentId', 'venueId', 'layout', 'user', 'streamId', 'player2id', 'error'} for data_change,
  • {visible: boolean} for odds_click,
  • {source: widget.name, target: facebook|twitter} for social_share,
  • {error: string} for license_error.

Example

JS/Example of using Event Handler

<script>
    (function(a,b,c,d,e,f,g,h,i){a[e]||(i=a[e]=function(){(a[e].q=a[e].q||[]).push(arguments)},i.l=1*new Date,i.o=f,
    g=b.createElement(c),h=b.getElementsByTagName(c)[0],g.async=1,g.src=d,g.setAttribute("n",e),h.parentNode.insertBefore(g,h)
    )})(window,document,"script","https://widgets.media.sportradar.com/uscommon/widgetloader","USW", {
        language: 'en_us'
    });
    USW('addWidget', '#sr-widget', 'us.common.matchList', {sportId: 1, onTrack: function(param1, param2){alert('param1: ' + param1 + ' param2: ' + JSON.stringify(param2))}});
</script>
<div id="sr-widget"></div>