In This Article
Introduction
Our client-side APIs are a collection of events and APIs that can be used by any integration that injects JavaScript into a Wix site using the Embedded Script component.
The events can give your app real-time information about the site, the content viewed, and user actions. This reference documents every object and method available. You can use these APIs to make your app react to user actions or learn about user behavior. In addition, you can use the API to report and listen to custom events sent by other apps.
On-Ready Event
To make sure you aren't calling the event before it is fully initiated, here is an on-ready event you can listen to:
Copy
1function registerListener() {2 window.wixDevelopersAnalytics.register('head', 3 (eventName, eventParams) => console.log('wix dev head', eventName, eventParams));4}5
6window.wixDevelopersAnalytics ?7 registerListener() :8 window.addEventListener('wixDevelopersAnalyticsReady', registerListener);
Listening to a Predefined Wix Event
Add this code to your embedded script component, and make sure to point to the events you are interested in:
Copy
1window.wixDevelopersAnalytics.register('app-ID', function report(eventName, data) { 2 switch(eventName) { 3 case 'pageview':4 callMyPageViewFunction(data); 5 break; 6 case 'addToCart':7 callMyAddToCartFunction(data); 8 break;9 }10}
Was this helpful?
Yes
No