You can track analytics events in your Wix-managed headless project using the @wix/site package. Use trackEvent() to send standard and custom events from your headless site. Events are sent to the Wix analytics infrastructure and can be forwarded to connected external platforms such as Google Analytics (GA4), Facebook Pixel, or Google Tag Manager.
To track analytics events in a headless site:
@wix/site package.@wix/site packageRun the following command in your project directory:
Then import the analytics module in any file where you want to track events:
Note: In Wix-managed headless, the CLI handles authentication automatically. You don't need to create a Wix client or configure OAuth — just import and call SDK methods directly.
Use trackEvent() to send standard analytics events. These events are recognized by external analytics platforms like Google Analytics and Facebook Pixel.
The following standard events are supported:
| Event Name | Description |
|---|---|
AddPaymentInfo | Visitor saves payment information. |
AddProductImpression | Visitor views a product. |
AddToCart | Visitor adds a product to the cart. |
CheckoutStep | Visitor completes a checkout step. |
ClickProduct | Visitor clicks on a product. |
CompleteRegistration | Visitor completes registration. |
InitiateCheckout | Visitor starts the checkout process. |
Lead | Visitor submits a form or subscribes to a newsletter. |
Purchase | Customer completes a purchase. |
RemoveFromCart | Visitor removes a product from the cart. |
Schedule | Visitor schedules a meeting or appointment. |
StartPayment | Visitor starts the payment process. |
ViewContent | Visitor views a key page, such as a product page. |
For a full reference of event properties, see About Analytics Events.
Track a product view:
Track a completed purchase:
You can also track custom events for business-specific actions not covered by the standard event types. Pass "CustomEvent" as the event name and include your custom data in the event data object:
Custom events are forwarded to connected analytics platforms along with the data you provide.
To forward tracked events to an external analytics platform, connect one or more of the following from your site dashboard:
Once connected, standard and custom events sent with trackEvent() are forwarded to the platform automatically.
Analytics events are only sent to the Wix analytics infrastructure on your deployed site. The analytics scripts that handle event delivery are injected during the production build.
To build and deploy your site:
Note: During local development with wix dev, trackEvent() calls execute without errors, but events aren't delivered to the analytics backend. To verify that events are being tracked, deploy your site and check your Wix dashboard analytics or connected external platform.