Track Analytics Events

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:

  1. Install the @wix/site package.
  2. Track standard events.
  3. Optionally, track custom events.
  4. Connect external analytics platforms (optional).
  5. Deploy your site.

Prerequisites

  • A Wix-managed headless project. See Quick Start a Headless Project.
  • A custom domain connected to your site. Analytics events are only delivered on sites with a custom domain.

Step 1 | Install the @wix/site package

Run the following command in your project directory:

Copy

Then import the analytics module in any file where you want to track events:

Copy

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.

Step 2 | Track standard events

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 NameDescription
AddPaymentInfoVisitor saves payment information.
AddProductImpressionVisitor views a product.
AddToCartVisitor adds a product to the cart.
CheckoutStepVisitor completes a checkout step.
ClickProductVisitor clicks on a product.
CompleteRegistrationVisitor completes registration.
InitiateCheckoutVisitor starts the checkout process.
LeadVisitor submits a form or subscribes to a newsletter.
PurchaseCustomer completes a purchase.
RemoveFromCartVisitor removes a product from the cart.
ScheduleVisitor schedules a meeting or appointment.
StartPaymentVisitor starts the payment process.
ViewContentVisitor views a key page, such as a product page.

For a full reference of event properties, see About Analytics Events.

Examples

Track a product view:

Copy

Track a completed purchase:

Copy

Step 3 | Track custom events (optional)

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:

Copy

Custom events are forwarded to connected analytics platforms along with the data you provide.

Step 4 | Connect external analytics platforms (optional)

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.

Step 5 | Deploy your site

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:

Copy

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.

See also

Did this help?