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
1
trackEvent(eventName, params)

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
1
Wix.Analytics.trackEvent('ViewContent', {
2
sku: 'P12345',
3
name: 'Really Fast Running Shoes',
4
category: 'Apparel/Shoes',
5
price: 150,
6
currency: 'USD',
7
brand: 'New Balance',
8
variant: 'Blue',
9
list: 'Search Results',
10
position: 1
11
});

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
1
origin, **contents**\[{id, sku, **name**, price, currency, category, brand, variant, list, position}\]

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
1
Wix.Analytics.trackEvent('AddProductImpression', {
2
origin: My Shoe Store',
3
contents: [{
4
sku: 'P12345',
5
name: 'Really Fast Running Shoes',
6
category: 'Apparel/Shoes',
7
price: 100,
8
currency: 'USD',
9
brand: 'Nike',
10
variant: 'Black',
11
list: 'Search Results',
12
position: 1
13
}]
14
});

ClickProduct

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

Syntax:

Copy
1
{origin, id, sku, **name**, price, currency, category, brand, variant, list, position}

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
1
Wix.Analytics.trackEvent('ClickProduct', {
2
origin: 'My Shoe Store',
3
id: 'P12345',
4
name: 'Really Fast Running Shoes',
5
category: 'Apparel/Shoes',
6
price: 120,
7
currency: 'USD',
8
brand: 'Adidas',
9
variant: 'Black',
10
position: 1
11
});

ViewContent

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

Syntax:

Copy
1
{origin, id, sku, **name**, price, currency, category, brand, variant, list, position}

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
1
Wix.Analytics.trackEvent('ViewContent', {
2
origin: 'My Shoe Store',
3
sku: 'P12345',
4
name: 'Really Fast Running Shoes',
5
category: 'Apparel/Shoes',
6
price: 150,
7
currency: 'USD',
8
brand: 'New Balance',
9
variant: 'Blue',
10
list: 'Search Results',
11
position: 1
12
});

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
1
{origin, id, sku, **name**, price, currency, category, brand, variant, list, position, quantity}

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
1
Wix.Analytics.trackEvent('AddToCart', {
2
origin: 'My Shoe Store',
3
id: 'P12345',
4
name: 'Really Fast Running Shoes',
5
category: 'Apparel/Shoes',
6
price: 120.5,
7
currency: 'USD',
8
brand: 'Saucony',
9
variant: 'Silver',
10
position: 2,
11
quantity: 1
12
});

RemoveFromCart

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

Syntax:

Copy
1
{origin, id, **name**, price, currency, category, brand, variant, position, quantity}

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
1
Wix.Analytics.trackEvent('RemoveFromCart', {
2
origin: 'My Shoe Store',
3
id: 'P12346',
4
name: 'Really Fast Running Shoes',
5
price: 125.95,
6
currency: 'USD',
7
category: 'Apparel/Shoes',
8
brand: 'Adidas',
9
variant: 'Black',
10
position: 1,
11
quantity: 1
12
});

InitiateCheckout

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

Syntax:

Copy
1
origin, **contents**\[{id, sku, **name**, price, currency, category, brand, variant, quantity}\]

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
1
Wix.Analytics.trackEvent('InitiateCheckout', {
2
origin: 'My Shoe Store',
3
contents: [ {
4
sku: 'P12345',
5
name: 'Really Fast Running Shoes',
6
category: 'Apparel/Shoes',
7
price: 100,
8
currency: 'USD',
9
brand: 'Nike',
10
variant: 'Black',
11
quantity: 2
12
},
13
{
14
sku: 'P67890',
15
name: 'Running Shirt',
16
category: 'Apparel/Shirts',
17
price: 50,
18
currency: 'USD',
19
brand: 'Nike',
20
variant: 'Blue',
21
quantity: 3
22
}]
23
});

StartPayment

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

Syntax:

Copy
1
{origin, option}

Parameters:

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

Example:

Copy
1
Wix.Analytics.trackEvent('StartPayment', {
2
origin: 'My Shoe Store',
3
option: 'Fast Checkout'
4
});

AddPaymentInfo

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

Syntax:

Copy
1
{origin, option}

Parameters:

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

Example:

Copy
1
Wix.Analytics.trackEvent('AddPaymentInfo', {
2
origin: 'My Shoe Store',
3
option: 'Visa'
4
});

CheckoutStep

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

Syntax:

Copy
1
{origin, step, action, option}

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
1
Wix.Analytics.trackEvent('CheckoutStep', {
2
origin: 'My Shoe Store',
3
step: '3',
4
action: 'Select Shipping',
5
option: 'Fast Checkout'
6
});

Purchase

Report this event when a purchase is completed successfully.

Syntax:

Copy
1
{origin, **id**, affiliation, revenue, tax, shipping, coupon, **contents**}

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
1
Wix.Analytics.trackEvent('Purchase', {
2
origin: 'My Shoe Store',
3
id: 'T12345',
4
affiliation: 'My Store',
5
revenue: '22.16',
6
tax: '2.85',
7
shipping: '5.34',
8
coupon: 'SUMMER2013',
9
contents: [ {
10
id: 'ABC123',
11
quantity: 2,
12
price: 1.99,
13
currency: 'USD',
14
},
15
{
16
id: 'XYZ789',
17
quantity: 1,
18
price: 9.99,
19
currency: 'USD',
20
} ]
21
});

Lead

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

Example:

Copy
1
Wix.Analytics.trackEvent('Lead');

CustomEvent

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

Syntax:

Copy
1
{event, \*}

Parameters:

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

Example:

Copy
1
Wix.Analytics.trackEvent('CustomEvent', {
2
event: 'FrequentShopper',
3
num_purchases: 8,
4
average_order: 245.24,
5
favorite_category: 'Sporting Goods'
6
});

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
1
Wix.Analytics.reportCampaignEvent(Wix.Analytics.PixelEventType.PURCHASE.eventName, {value: 50, currency: 'USD'});

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
1
Wix.Analytics.registerCampaignPixel(Wix.Analytics.PixelType.FACEBOOK, '1234567890');
Was this helpful?
Yes
No