Passing Functions to embed.js

Using embed.js comes with additional feature, you can pass a function that already exists within your site by using data-lm-callback.

This function will be called when user clicks on the video instead of link that is normally passed by data-lm-link.

We would advise to use a function that can be used globally or is attached to window element, so like data-lm-callback="window.yourFunction();" or data-lm-callback="yourFunction();"

Few examples:

<script src="https://linktoyourwebsite.com/path/to/embed.js" data-lm-partner="partner" data-lm-link="https://link/to/your/video" data-lm-callback="() => console.log('test');"></script>
<script src="https://linktoyourwebsite.com/path/to/embed.js" data-lm-partner="partner" data-lm-link="https://link/to/your/video" data-lm-callback="console.log('test');"></script>
<script src="https://linktoyourwebsite.com/path/to/embed.js" data-lm-partner="partner" data-lm-link="https://link/to/your/video" data-lm-callback="yourFunction();"></script>
<script src="https://linktoyourwebsite.com/path/to/embed.js" data-lm-partner="partner" data-lm-link="https://link/to/your/video" data-lm-callback="window.yourFunction();"></script>