Skip to main content

Purchase Confirmation Pixel

The purchase confirmation pixel allows you to track and analyze customer purchases within your ecommerce website. By integrating this pixel onto your checkout screen, you can gather valuable data and insights on how Alby performs with your website. Follow the steps below to add the purchase confirmation pixel and pass the necessary variables.

Prerequisites

Before proceeding with the installation, make sure you have the following information ready:

  1. Your Brand ID (brand_id): This unique identifier connects your website to Alby. You can obtain this ID from your Alby contact.

Inserting the Purchase Confirmation Pixel with JavaScript

To add the purchase confirmation pixel using JavaScript, follow these instructions:

  1. Open your website's source code.
  2. Locate the checkout screen code or the specific section where the purchase confirmation pixel should be placed.
  3. Add the following code inside it:
<script>
var _ALBY_ORDER_INFO = {
brand_id: "PLACE_BRAND_ID_HERE",
order_id: "PLACE_ORDER_ID_HERE",
order_total: "PLACE_ORDER_TOTAL_HERE",
product_ids: ["PRODUCT IDS HERE"],
currency: "PLACE_CURRENCY_HERE",
};

var url =
"https://tr.alby.com/p?" +
(function (i) {
if (i instanceof Object) {
var s = [];
for (var o in i)
if (i[o]) {
var r = i[o],
e = encodeURIComponent(o) + "=" + encodeURIComponent(r);
s.push(e);
}
return s.join("&");
}
return "";
})(_ALBY_ORDER_INFO),
cookies = document.cookie.split(";"),
sessionCookie = cookies.filter(function (i) {
return i.trim().startsWith("_alby_session=");
})[0],
userCookie = cookies.filter(function (i) {
return i.trim().startsWith("_alby_user=");
})[0];
sessionCookie && (url += "&session=" + sessionCookie.split("=")[1]),
userCookie && (url += "&user_id=" + userCookie.split("=")[1]),
fetch(url);
</script>

Configuring the Purchase Confirmation Pixel

In the code snippet from earlier, you need to replace the following variables with the appropriate values:

  • brand_id: Your Brand ID.
  • order_id: A unique identifier for the purchase.
  • order_total: The total amount of the purchase, rounded to the nearest whole unit of the respective currency.
  • product_ids: A comma-delimited list of variant/child level product IDs shared with Alby through your product catalog integration. Alby wants to observe purchases at a variant level for more robust conversion reporting.
  • currency: The currency code (e.g., USD, EUR, GBP) in which the purchase was made.

Save and Publish

Save the changes you made to your source code and publish your website. The purchase confirmation pixel will now be fired on the checkout screen, capturing the necessary data for analysis.

If you encounter any issues or have further questions, don't hesitate to reach out to our support team for assistance.