I’m building a custom ordering flow and want to track events. I’m using wixWindows.trackEvent but the events AddToCart , InitiateCheckout , and Purchase are not working (doesn’t show up for FB Pixel or Google Analytics). Interestingly, trackEvent(" Lead ") does work for both.
I suspect the problem is that some events require specific parameters. I checked the API reference page for trackEvent but they’re not listed there. For example, it just says the parameter for the “AddToCart” is “AddToCartEvent” but doesn’t explain what should be defined in “AddToCartEvent.”
https://www.wix.com/velo/reference/wix-window/trackevent
Here’s an example of an event that is working :
export function buttonAddToSubscribe_click(event) {
wixWindow.trackEvent("Lead");
}
Here’s an example of an event that is not working:
export function buttonAddToCart_click(event) {
wixWindow.trackEvent("AddToCart");
}
Thank you!
Bump. Any help would be greatly appreciated!
Hey Sam,
I agree that the information available on that reference page is lacking detail. A key bit of information they don’t list is that “Lead” is the only one that doesn’t take parameters, and all the others must have parameters to work.
So for “AddToCart” you would need to use a data object as the second function parameter like the below example. All of the options seem to work using this format, and I have been able to get them to fire on the Pixel test area.
import wixWindow from 'wix-window';
wixWindow.trackEvent("AddToCart", {
"origin": "My Sportswear Store",
"id": "P12345",
"name": "Really Fast Running Shoes",
"category": "Apparel/Shoes",
"price": 120,
"currency": "USD",
"brand": "SomeBrand",
"variant": "Black",
"position": 1
} );
I have experimented with removing some of the options, and it seems that you can drop some of the things in that list, but for best results, I would keep them and just put “N/A” after the line that you don’t need. I.e if all you wanted was the name of the item and the price, you could write it like this:
import wixWindow from 'wix-window';
wixWindow.trackEvent("AddToCart", {
"origin": "N/A",
"id": "N/A",
"name": "Really Fast Running Shoes",
"category": "N/A",
"price": 120, // must be a number format.
"currency": "USD", // must be included for price to work.
"brand": "N/A",
"variant": "N/A",
"position": null // this last option must satisfy a number type if you keep it.
} );
Hope this works for you!
Thanks Rory! I’ll give that a try.