Website integration

Install the Hulla Pixel

How to add the Hulla Pixel to your site, pass your shoppers' cookie choice, and send the page view and checkout events that measure what your Hullabalook experiences earn.

The Hulla Pixel is a small script that records how shoppers move through your site, from the pages they view to the orders they place. It connects those orders to the Hullabalook experiences that shoppers used on the way, which gives your dashboards their conversion and revenue figures. The same data feeds recommendations and other experiences that change with what a shopper does.

The pixel sends its events straight to Hullabalook, so experiences can use them within seconds. It works alongside Google Analytics and doesn't replace it.

What you need

Your Hullabalook contact gives you two things before you start:

1. Add the script

Add this tag to the <head> of every page, before the hintegrate script if you also use experiences:

<script
  src="https://<your-name>.hulla-cdn.com/scripts/hulla-pixel.min.js"
  data-pixel-id="<your pixel ID>"
  data-pixel-currency="GBP"
  data-pixel-region="GBR"
></script>
AttributeRequiredWhat it does
data-pixel-idYesYour pixel ID. Without it, the pixel doesn't start and logs an error in the console.
data-pixel-currencyNoThe page's currency, as an ISO 4217 code such as GBP or EUR. It is GBP if you leave it out.
data-pixel-regionNoThe shopper's country, as a three-letter ISO 3166 code such as GBR or IRL. It is GBR if you leave it out.
data-pixel-segmentNoA label for the group of shoppers the page serves, such as trade or retail, if your Hullabalook contact has agreed segments with you.
data-pixel-debugNoSet it to true while you test. The pixel then logs each event in the console and sends nothing.
data-pixel-validate-onlyNoSet it to true to check every event without sending any. Each call still returns whether its event was valid.

Load the pixel before hintegrate. Hintegrate gives each experience the pixel's session when the experience starts, and it can't add the session afterwards.

Once the script has loaded, get the pixel with your shopper's cookie choice, the currency and the region:

<script>
  const consented = /* true if the shopper accepted analytics cookies */;
  const pixel = HullaPixel.getInstance(consented, "GBP", "GBR");
</script>

Every site uses its own consent tool, so read the shopper's choice from yours. If you leave the choice out, the pixel assumes the shopper agreed, so always pass it. Without consent, the pixel sets no cookies and removes any it set before. It keeps what it needs to connect an order to an experience in the browser's own storage for one hour at most, rather than in a cookie for 30 days.

If the shopper changes their choice, or the currency changes, call HullaPixel.getInstance again with the new values. You can also call pixel.setCurrency("EUR") on its own.

3. Send a page view on every page

pixel.pageView();

On a product page, also say which product it is:

pixel.pageView({ productSku: "SKU-12345" });

4. Send the checkout events

The checkout events are the ones that matter most, because they connect orders to the experiences that led to them. Send checkoutBegin when the shopper starts checking out, and checkoutComplete on the order confirmation page.

Describe each product with HullaPixel.Product.create, and give its place in the basket with HullaPixel.PositionalProduct.create:

const products = basket.map((line, index) =>
  HullaPixel.PositionalProduct.create({
    product: HullaPixel.Product.create({
      sku: line.sku,
      url: line.url,
      name: line.name,
      price: line.price,
      category: line.category,
      subcategory: line.subcategory,
    }),
    position: index,
  }),
);

const begun = await pixel.checkoutBegin({ products, amount: basketTotal });
if (begun.success) {
  sessionStorage.setItem("hullaCheckoutId", begun.data.checkoutId);
}

checkoutBegin returns a checkoutId that ties the start of the checkout to its end. Keep it until the confirmation page, for example in sessionStorage as above, and pass it to checkoutComplete with the products the shopper bought:

await pixel.checkoutComplete({
  checkoutId: sessionStorage.getItem("hullaCheckoutId") ?? orderNumber,
  products,
  amount: orderTotal,
});

checkoutComplete needs a checkoutId, and it doesn't send the order without one. The confirmation page can't read the stored id when the checkout ends on another domain, such as a payment provider's page, or in another tab. Pass your own order number then, as above, so that the order is still recorded.

The pixel checks every event before sending it:

Each call returns { success: true }, or { success: false, error } with what was wrong. Check the result while you test, because an event that fails its check is never sent. The event methods never throw, but Product.create and PositionalProduct.create throw an error for a product that fails its check. Build your products inside a try block, so that one bad product can't stop the rest of your page's script.

Adding your own details to an event

Every event takes an optional customEventParameters, for details of your own that you want to report on later:

await pixel.checkoutComplete({
  checkoutId,
  products,
  amount: orderTotal,
  customEventParameters: {
    path: ["checkout", "express"],
    custom: { paymentMethod: "card", deliveryOption: "next-day" },
  },
});

path takes up to three steps that describe where the event happened. custom takes your own keys, with text, numbers, true or false, lists, or nested objects as values. Products also take customFields in the same form. Don't put a shopper's name, email address or other personal details in either.

Other events you can send

If your own pages have these actions, sending them gives a fuller picture of each shopper's visit. Each takes a list of products made in the same way as at checkout:

MethodWhen to send it
addToBagAttempt and addToBagSuccessThe shopper presses add to bag, and then the basket confirms it. The first returns an atbId that you pass to the second.
addToWishlist and removeFromWishlistThe shopper saves or removes a product.
productSeenProducts come into view in a list or a grid.
productClickThroughThe shopper opens a product from a list or a grid.

Hullabalook experiences send their own events, including add to bag from inside an experience, so you don't need to send those yourself.

Checking it works

  1. Set data-pixel-debug="true" and open the page with the browser console open. Each event is logged there as [DEBUG] and nothing is sent. The pixel logs at the console's debug level, which Chrome shows only when you choose Verbose in the console's levels menu.
  2. Run through a test order and check that checkoutBegin and checkoutComplete each return success: true.
  3. Remove data-pixel-debug, place a real test order, and ask your Hullabalook contact to confirm that it arrived.

The pixel and Google Analytics

Google Analytics is built for reports, and its data is ready hours after a visit. The Hulla Pixel's events reach Hullabalook as they happen, in a shape built for products and baskets. Experiences can therefore respond to what a shopper does during the same visit. Keep Google Analytics for your marketing and business reporting, and use the pixel for the features that need data straight away.