Use onTrack function as a prop to every widget. This function will be invoked whenever any of specified events occurs:
- 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. - odds_click - user clicks on an odds button.
- social_share - user clicks on social share button,
- license_error - widget returns a licensing error.
Function emits two parameters containing triggered event (param1) and object with relevant data (param2).
Name | Type | Description |
---|---|---|
param1 | string |
Type of triggered event, contains one of the following strings:
|
param2 | object |
Relevant data, object, contains data depending on the event type:
|
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.sir.sportradar.com/sportradar/widgetloader","SIR", {
language: 'en'
});
SIR('addWidget', '#sr-widget', 'match.matchList', {sportId: 1, onTrack: function(param1, param2){alert('param1: ' + param1 + ' param2: ' + JSON.stringify(param2))}});
</script>
<div id="sr-widget"></div>