About the Embedded Script SDK

The embedded script SDK allows apps with embedded script components to:
  • Listen to predefined Wix events 
  • Report and listen to custom events 
Note:
This SDK isn't related to or dependent on the old JS SDK

Listening to a predefined Wix event

Add this code to your embedded script component, and make sure to point to the events you're interested in. You also need to change 'app-ID' to your own unique App ID for the code to work.
1
2
3
4
5
6
7
8
9
10
11
12
<script id='my_app_js' src='https://cdn.domain.com/pixel.js?id={{pixel_id}}' async='true'></script> 
<script> 
window.wixDevelopersAnalytics.register('app-ID', function report(eventName, data) { 
    switch(eventName) { 
    case 'pageview':
      callMyPageViewFunction(); 
      break; 
    case 'addToCart':
      callMyAddToCartFunction(); 
      break;
});
</script>

Predefined Wix Events

  • addProductImpression: When a user views a product. 
  • clickProduct: When a user clicks on a product.
  • viewContent: When a key page is viewed.
  • addToCart: When a user adds a product to the shopping cart.
  • removeFromCart: When a user removes a product from the shopping cart. 
  • initiateCheckout: When a user starts the checkout process.
  • startPayment: When a user starts the payment process.
  • addPaymentInfo: When a user saves payment information.
  • checkoutStep: When a user completes a custom checkout step. 
  • purchase: When the checkout process is complete.
  • lead: When a user subscribes to a newsletter or submits a contact form.

Reporting a custom event

Call a trigger event, passing the following properties:
  • eventName
  • eventData / eventParams – an object with the data to be passed
1
window.wixDevelopersAnalytics.triggerEvent(<'FORMSUBMIT'>, {name: <'TEST'>})

Reporting and listening to a custom event

Add this code to your embedded script component, and make sure you point to your custom events. You'll also need to change 'app-ID' to your own unique App ID for the code to work.
1
2
3
4
5
6
7
8
9
10
<script>
window.wixDevelopersAnalytics.register('app-ID', function report(eventName, data) {
  console.log('eventName: '+eventName);  
});

setTimeout(function(){ 
  window.wixDevelopersAnalytics.triggerEvent('newEvent', {eventName: 'eventName'})
}, 5000);

</script>

On-ready event

To make sure you aren't calling the SDK before it is fully initiated, here's an on-ready event you can listen to. You'll also need to change 'app-ID' to your own unique App ID for the code to work.
1
2
3
4
5
6
7
window.addEventListener('wixDevelopersAnalyticsReady', registerListener)

function registerListener(){
  window.wixDevelopersAnalytics.register('app-ID', function report(eventName, data) { 
    console.log("New Event: "+eventName+" | Data: "+JSON.stringify(data))
});
};

Response data

The returned data will vary based on the specific event, but will always include the following:
  • isPremium: true if the site owner has a premium plan, false if they have a free plan.
  • uuid: The site owner's unique ID in Wix.
  • msid: The unique ID of the Wix Site.

Related Content