Conversion (purchase) event tracking

You may want to track custom events or fire a script when a purchase happens, for example to track conversions. This script can help you do this when you're using the checkout embed or checkout pop-up.

Tracking conversion (purchase) events on your website

You can use the following script as a starting point. If you're not familiar with JavaScript, we recommend working with a developer to help you set up the script. We also offer paid technical support; just get in touch via the support chat.

The following script should be added to your own website, on each page where you have added your checkout and the customer will make the purchase.

<script type="text/javascript">
 window.addEventListener("message", function (event) {

   // check if event is from Checkout Page
   if (event.data.type && event.data.type === "checkoutpage.event") {
     
     // check if event is a checkout (purchase) event
     if (event.data.payload.event === "checkout") {
       // track purchase event here
       console.log(event.data.payload);
     }
   }
 });
</script>

The event.data.payload contains the following data:

  • event: "checkout"
  • checkoutId: the ID of your checkout
  • orderId: the ID of your customer's order
  • customerEmail: your customer's email address
  • value: the final purchase amount
  • currency: the currency of the purchase