> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt ## Resource: Track Analytics Events ## Article: Track Analytics Events ## Article Link: https://dev.wix.com/docs/go-headless/develop-your-project/wix-managed-headless/analytics-events/track-analytics-events.md ## Article Content: # Track Analytics Events You can track analytics events in your [Wix-managed headless project](https://dev.wix.com/docs/go-headless/develop-your-project/about-headless-development-paths.md) 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. 1. Track standard events. 1. Optionally, track custom events. 1. Connect external analytics platforms (optional). 1. Deploy your site. ## Prerequisites - A Wix-managed headless project. See [Quick Start a Headless Project](https://dev.wix.com/docs/wix-cli/guides/get-started/quick-start-a-headless-project.md). - 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: ```bash npm install @wix/site ``` Then import the `analytics` module in any file where you want to track events: ```javascript import { analytics } from "@wix/site"; ``` > **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()`](https://dev.wix.com/docs/sdk/host-modules/site/analytics/track-event.md) 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](https://dev.wix.com/docs/sdk/host-modules/site/events/about-analytics-events.md). ### Examples **Track a product view:** ```javascript import { analytics } from "@wix/site"; analytics.trackEvent("ViewContent", { origin: "Stores", id: "df19c1f7-07d8-a265-42f8-e8dfa824cc6e", name: "Soundbeam ERD - 3083", price: 220, currency: "USD", category: "All Products" }); ``` **Track a completed purchase:** ```javascript import { analytics } from "@wix/site"; analytics.trackEvent("Purchase", { origin: "Stores", id: "df19c1f7-07d8-a265-42f8-e8dfa824cc6e", orderId: "d86d077c-c5d2-42c6-8b15-f5e26f276807", revenue: 93.6, currency: "USD", contents: [ { id: "P001", name: "Running Shoes", price: 93.6, quantity: 1 } ] }); ``` ## 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: ```javascript import { analytics } from "@wix/site"; analytics.trackEvent("CustomEvent", { eventCategory: "User Engagement", eventAction: "Share Product", eventLabel: "Social Media" }); ``` 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: - [Google Analytics](https://support.wix.com/en/article/tracking-events-on-your-wix-site-with-a-google-analytics-property) - [Facebook Pixel](https://support.wix.com/en/article/connecting-a-facebook-pixel-to-your-wix-site) - [Google Tag Manager](https://support.wix.com/en/article/connecting-google-tag-manager-to-your-wix-site) 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: ```bash wix build wix release ``` > **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 - [`trackEvent()` API reference](https://dev.wix.com/docs/sdk/host-modules/site/analytics/track-event.md) - [About Analytics Events](https://dev.wix.com/docs/sdk/host-modules/site/events/about-analytics-events.md) - [Tracking Events on Your Wix Site with a Google Analytics Measurement ID](https://support.wix.com/en/article/tracking-events-on-your-wix-site-with-a-google-analytics-property) - [Connecting a Facebook Pixel to Your Wix Site](https://support.wix.com/en/article/connecting-a-facebook-pixel-to-your-wix-site)