Wix.Analytics

trackEvent

Reports an event in the live site to the user’s analytics tool, like Facebook Pixel or Google Analytics.

SDK Version: SDK 1.93.0+
Display: Live Site
Components: Widget, Pinned (aka Fixed-Position) Widget, Page, Worker

Syntax:

Copy

Parameters:

NameTypeDescription
eventName (required)StringName of the event, as specified in the list below.You can also define a custom event.
params (required)ObjectObject with key/value pairs required to report this event

Example:

Copy

Events

You can report the following events with trackEvent:

  • AddProductImpression – When a visitor views a product
  • ClickProduct – When a visitor clicks on a product
  • ViewContent – When a key page is viewed (such as a product page)
  • AddToCart – When a visitor adds a product to the shopping cart
  • RemoveFromCart – When a visitor removes a product from shopping cart
  • InitiateCheckout – When a visitor starts the checkout process
  • AddPaymentInfo – When the visitor saves payment information
  • Purchase – When the checkout process is complete
  • Lead – When a visitor subscribes to a newsletter or submits a contact form
  • CustomEvent – When a visitor performs an event not listed above

Important:
In these events we refer to “products”, but a product can be any important item the user is tracking, like a service, event, music track or album, etc.

AddProductImpression

Report this event when a visitor views a product or item.

Syntax:

Copy

Parameters:

NameTypeDescription
originStringOrigin of the event (e.g. Music Player, Contact Form)
contents (required)Array[Objects]Key/value pairs with more details about the product
contents.idStringProduct ID
contents.skuStringSKU number for the product
contents.name (required)StringName of the product
contents.priceNumberPrice of the product
contents.currencyStringCurrency code (e.g., EUR, USD, CAD)
contents.categoryStringCategory the product is listed under (e.g., ‘Accessories/Watches’)
contents.brandStringBrand name of the product (e.g., ‘Nike’)
contents.variantStringVariant of the product (like a specific color or size)
contents.listStringList or collection the item is in (e.g., ‘Product Gallery’ or ‘Search Results’)
contents.positionNumberPosition of this item within a list or collection (e.g., 1)

Example:

Copy

ClickProduct

Report this event when a visitor clicks on a product or item.

Syntax:

Copy

Parameters:

NameTypeDescription
originStringOrigin of the event (e.g. Music Player, Contact Form)
idStringProduct ID
skuStringSKU number for this product
name (required)StringName of the product
priceNumberPrice of the product
currencyStringCurrency code (e.g., EUR, USD, CAD)
categoryStringCategory this product is listed under (e.g., ‘Accessories/Watches’)
brandStringBrand name of the product (e.g., ‘Nike’)
variantStringVariant of this product (like a specific color or size)
listStringList or collection the item is in (e.g., ‘Product Gallery’ or ‘Search Results’)
positionNumberPosition of this item within a list or collection (e.g., 1)

Example:

Copy

ViewContent

Report this event when a visitor views a key page, like the product page.

Syntax:

Copy

Parameters:

NameTypeDescription
originStringOrigin of the event (e.g. Music Player, Contact Form)
idStringProduct ID
skuStringSKU number for this product
name (required)StringName of the product
priceNumberPrice of the product
currencyStringCurrency code (e.g., EUR, USD, CAD)
categoryStringCategory this product is listed under (e.g., ‘Accessories/Watches’)
brandStringBrand name of the product (e.g., ‘Nike’)
variantStringVariant of this product (like a specific color or size)
listStringList or collection the item is in (e.g., ‘Product Gallery’ or ‘Search Results’)
positionNumberPosition of this item within a list or collection (e.g., 1)

Example:

Copy

AddToCart

Report this event when a visitor clicks a button to add a product to the shopping cart (e.g., when the Add to Cart button is clicked).

Syntax:

Copy

Parameters:

NameTypeDescription
originStringOrigin of the event (e.g. Music Player, Contact Form)
idStringProduct ID
skuStringSKU number for this product
name (required)StringName of the product
priceNumberPrice of the product
currencyStringCurrency code (e.g., EUR, USD, CAD)
categoryStringCategory this product is listed under (e.g., ‘Accessories/Watches’)
brandStringBrand name of the product (e.g., ‘Nike’)
variantStringVariant of this product (like a specific color or size)
positionNumberPosition of this item within a list or collection (e.g., 1)
quantityNumberProduct quantity

Example:

Copy

RemoveFromCart

Report this event when a visitor clicks a button to remove a product from the shopping cart.

Syntax:

Copy

Parameters:

NameTypeDescription
originStringOrigin of the event (e.g. Music Player, Contact Form)
idStringProduct ID
name (required)StringName of the product
priceNumberPrice of the product
currencyStringCurrency code (e.g., EUR, USD, CAD)
categoryStringCategory this product is listed under (e.g., ‘Accessories/Watches’)
brandStringBrand name of the product (e.g., ‘Nike’)
variantStringVariant of this product (like a specific color or size)
positionNumberPosition of this item within a list or collection (e.g., 1)
quantityNumberProduct quantity

Example:

Copy

InitiateCheckout

Report this event when a visitor clicks a button to begin the checkout process.

Syntax:

Copy

Parameters:

NameTypeDescription
originStringOrigin of the event (e.g. Music Player, Contact Form)
contents (required)Array[Objects]Key/value pairs with more details about the product
contents.idStringProduct ID
contents.skuStringSKU number for the product
contents.name (required)StringName of the product
contents.priceNumberPrice of the product
contents.currencyStringCurrency code (e.g., EUR, USD, CAD)
contents.categoryStringCategory the product is listed under (e.g., ‘Accessories/Watches’)
contents.brandStringBrand name of the product (e.g., ‘Nike’)
contents.variantStringVariant of the product (like a specific color or size)
contents.quantityNumberQuantity of this specific product a visitor is purchasing

Example:

Copy

StartPayment

Report this event when a visitor reaches a payment form, before making a purchase.

Syntax:

Copy

Parameters:

NameTypeDescription
originStringOrigin of the event (e.g. Music Player, Contact Form)
optionStringPayment type (e.g., 'Fast Checkout')

Example:

Copy

AddPaymentInfo

Report this event when a visitor clicks a button to save payment info for a purchase.

Syntax:

Copy

Parameters:

NameTypeDescription
originStringOrigin of the event (e.g. Music Player, Contact Form)
optionStringPayment type (e.g., ‘Visa’ or ‘PayPal’)

Example:

Copy

CheckoutStep

Report this event for any custom checkout interaction that a visitor completes between initiating a checkout and completing a purchase.

Syntax:

Copy

Parameters:

NameTypeDescription
originStringOrigin of the event (e.g. ‘Music Player’, or ‘Contact Form’)
stepStringCheckout flow step number. Make sure to report consistent step values (e.g. ‘3’ when step follows StartPayment and addPaymentInfo events)
actionStringThe action the visitor is taking in this step (e.g. ‘Select Shipping’)
optionStringPayment type (e.g., ‘Express Shipping’)

Example:

Copy

Purchase

Report this event when a purchase is completed successfully.

Syntax:

Copy

Parameters:

NameTypeDescription
originStringOrigin of the event (e.g. Music Player, Contact Form)
id (required)StringTransaction ID or order number
affiliationStringName of the store
revenueStringTotal amount for this purchase, including taxes, shipping, etc. (e.g., ‘5.99’)
taxStringTotal amount charged in taxes (e.g., ‘5.99’)
shippingStringTotal amount charged for shipping (e.g., ‘5.99’)
couponStringCoupon code applied to this purchase
contents (required)Array[Objects]Array of all product objects related to this purchase
contents.idStringProduct ID
contents.name (required)StringName of the product
contents.priceNumberPrice of the product
contents.currencyStringCurrency code (e.g., EUR, USD, CAD)
contents.categoryStringCategory the product is listed under (e.g., ‘Accessories/Watches’)
contents.brandStringBrand name of the product (e.g., ‘Nike’)
contents.variantStringVariant of the product (like a specific color or size)
contents.quantityNumberQuantity of this specific product a visitor is purchasing

Example:

Copy

Lead

Report this event when a visitor subscribes to a newsletter or submits a contact form.

Example:

Copy

CustomEvent

Report a custom event that doesn’t fit any of the standard events listed above.

Syntax:

Copy

Parameters:

NameTypeDescription
event (required)StringName of the event
paramCustomName of the parameter

Example:

Copy

Deprecated

reportCampaignEvent

SDK Version: Deprecated

Important:
Now that this method is deprecated, use trackEvent instead.

Reports an event that happened in your app on the live site. The event is sent to all registered pixels on the site – even pixels used in other apps.

Parameters:

NameTypeDescription
PixelEventType (required)Wix.Analytics.PixelEventType.[EVENT].eventNameThe event you are reporting. You can see the event descriptions in Facebook’s Pixel API. To make sure that the event matches Facebook’s API, enter the event name in this format: Wix.Analytics.PixelEventType.[EVENT].eventName, where [EVENT] is one of the following: VIEW_CONTENT, SEARCH, ADD_TO_CART, ADD_TO_WISHLIST, INITIATE_CHECKOUT, ADD_PAYMENT_INFO, PURCHASE, LEAD, COMPLETE_REGISTRATION, CUSTOM_EVENT. For example, Wix.Analytics.PixelEventType.PURCHASE.eventName returns the correct event name - ‘Purchase’.
dataObjectEnter the event parameters. To get a list of required and optional parameters for an event, use this method: Wix.Analytics.PixelEventType.[EVENT]. For more information, see Facebook’s Pixel API.

Example:

Copy

registerCampaignPixel

SDK Version: Deprecated

Registers and initializes the Facebook pixel on the live site. The pixel registration is saved for this session only, so call this method every time your app loads in the live site.

Parameters:

NameTypeDescription
pixelType (required)PixelTypeEnter Wix.Analytics.PixelType.FACEBOOK here
pixelId (required)StringA unique pixel identifier that was predefined by Facebook and is associated with a Facebook Ad account

Example:

Copy
Did this help?