Please ensure that you replace {clientId} with your unique client identifier, which was provided to you during the onboarding process.
Custom Event Handler
Once the widget is successfully loaded, it triggers an CustomEvent through the window object.
To handle this event effectively, create an event listener, allowing you to obtain the desired product reference and subsequently call the API for loading snippets tailored to the specific product in question.
window.addEventListener('lsc:widget:snippets:ready',({detail})=>{ // todo: replace static product reference definition with your logic // to obtain the actual product reference/id provided by your ecommerce // system.constreference='xyz'; // Invoke initialization of the snippets widget using the obtained // product referencedetail.player.initializeWithProduct(reference);});
Make sure to register the event listener before loading the widget to prevent missing the widget event and avoid any issues with loading the snippets.
Page Performance
In order to minimize any impact on your page speed and performance, remember to include the async and defer attributes when loading the widget.
Please note: The embed code handles the loading and initialization of all necessary resources automatically. There is no need to include any additional scripts on your website.