trackEvent( )


Deprecated

This method is deprecated.

Deprecated. This method will continue to work, but a newer version is available. Use the trackEvent() method instead.

Sends an event to analytics tools connected to a site. It can send events to Google Analytics, Facebook Pixel or analytics tools set up with the Google Tag Manager.

Migration Instructions

If this method is already in your code, it will continue to work. To stay compatible with future changes, migrate to trackEvent().

To migrate to the new function:

  1. Add the new import statement:

    Copy
  2. If you plan to migrate all functions that use trackEvent(), remove the original import { window } from "@wix/site-window"; statement.

  3. Look for any code that uses window.trackEvent(), and replace it with analytics.trackEvent(). Update your code to work with the new trackEvent() call and response properties.

    Note that the new trackEvent() method is not async.

  4. Test your changes to make sure your code behaves as expected.

Note: Check the new method documentation for any differences in parameters, return values, or behavior compared to the deprecated trackEvent() method.

Sends a tracking event to external analytics tools.

Learn more about:

Note: This method only runs on published versions of a site. It doesn't work when previewing a site.

The trackEvent() method lets you track both standard and custom events.

The following standard events are supported:

Standard EventDescriptionUsed By
AddPaymentInfoWhen a site visitor saves payment information.Google Analytics, Facebook Pixel
AddProductImpressionWhen a site visitor views a product.Google Analytics
AddToCartWhen a site visitor adds a product to the shopping cart.Google Analytics, Facebook Pixel
CheckoutStepWhen a site visitor completes a checkout step.Google Analytics
ClickProductWhen a site visitor clicks on a product.Google Analytics
CompleteRegistrationWhen a site visitor completes the registration. Note: The CompleteRegistration event doesn't take any parameters.Facebook Pixel
InitiateCheckoutWhen a site visitor starts the checkout process.Google Analytics, Facebook Pixel
LeadWhen a site visitor subscribes to a newsletter or submits a contact form.Google Analytics, Facebook Pixel
PurchaseWhen the customer successfully completes the checkout process.Google Analytics, Facebook Pixel
RemoveFromCartWhen a site visitor removes a product from the shopping cart.Google Analytics
ScheduleWhen a site visitor schedules a meeting or makes an appointment. Note: The Schedule event doesn't take any parameters.Facebook Pixel
StartPaymentWhen a site visitor starts the payment process.Google Analytics
ViewContentWhen a site visitor views a key page, for example the product page.Google Analytics, Facebook Pixel
Method Declaration
Copy
Method Parameters
eventNamestringRequired

Event name. Applies to both standard and custom events. The following standard events are supported:

  • AddPaymentInfo
  • AddProductImpression
  • AddToCart
  • CheckoutStep
  • ClickProduct
  • CompleteRegistration
  • InitiateCheckout
  • Lead
  • Purchase
  • RemoveFromCart
  • Schedule
  • StartPayment
  • ViewContent

parametersunionRequired

The event's parameters. Note: The CompleteRegistration and Schedule events don't take any parameters.

Did this help?