Set up events

Set up events on your website to measure the actions like making a purchase.

All events are tracked by calling the Pixel's wishiPixel(event, data) function, with the event name, and a JSON object as its parameters. For example, here's a function call to track when a visitor has viewed a product page:

window.wishiPixel('ProductViewed', {
  partnerUserId: "123-123",
  products: [
    {
      id: "1",
      name: "Name",
      buyUrl: "https://...",
      imageUrl: "https: //...",
      brand: "A name",
      price: 123.99,
      currency: "USD"
    }
  ]
});

You can call the wishiPixel(event, data) function anywhere between your web page's opening and closing <body> tags, either when the page loads, or when a visitor completes an action, such as clicking a button.

For example, if you wanted to track a standard purchase event after a visitor has completed the purchase, you could call the wishiPixel('CheckoutCompleted', data) function on your purchase confirmation page, like this:

<body>
  ...
  <script>
    wishiPixel('CheckoutCompleted', {data});
  </script>
  ...
</body>

If instead you wanted to track the same event when the visitor clicks a purchase button, you could tie the wishiPixel('CheckoutCompleted', data) function call to the purchase button on your checkout page, like this:

<button id="buyButton">Purchase</button>
<script type="text/javascript">
  $('#buyButton').click(function() {
    wishiPixel('CheckoutCompleted', {data});
  });
</script>

Note that the example above uses jQuery to trigger the function call, but you could trigger the function call using any method you wish.

Last updated