Skip to main content
A purchase event tells Northbeam that an order was completed in the visitor’s browser. Northbeam matches it to the order you send from your backend (through Shopify or the Orders API) and uses it to attribute that order. Every checkout flow on your site needs a purchase event. If one is missing, orders from that flow show as unattributed.

Which setup you need

Choose a function

Use fireSlimPurchaseEvent. It sends only the order ID, which is all Northbeam needs. Northbeam uses the order ID to match the purchase to your backend order. Revenue, tax, shipping, and line items always come from your backend order data (through Shopify or the Orders API), never from the browser. Fire the function on the Order Confirmation or Thank You page, after the order is complete. You can add it to your site’s code or through Google Tag Manager.

Requirements

Whichever function you use, it must:
Purchase data can’t be recovered later. If the event is set up incorrectly, those orders will be missing attribution. We strongly recommend that someone with basic JavaScript experience sets this up.

Match the order ID exactly

Northbeam uses the id value to match the purchase event to your backend order (the order_id you send through the Orders API). The two values must match exactly, including capitalization. If they don’t, the purchase won’t attribute.

Fire once per order

Your purchase event must fire exactly once for each order. If it fires more than once for the same order, Northbeam may not match the purchase to your backend order, and the order can show as unattributed.
Sending the same order more than once does not improve tracking. Duplicate purchase events can cause the order to lose its attribution.
Common causes of duplicate fires:
  • The customer refreshes or revisits the Order Confirmation page (for example, from a bookmark or a link in the confirmation email).
  • The script is installed twice (for example, hard-coded on the site and added in Google Tag Manager).
  • A Google Tag Manager trigger fires on more than one event (for example, both Page View and DOM Ready).
  • A single-page checkout re-renders the confirmation step.
To prevent this, make sure your checkout only fires the purchase event the first time the confirmation page loads for an order. Later page loads for the same order should not fire it again.

fireSlimPurchaseEvent

Sends only the order ID. This is the recommended function for every store.
Replace "A123" with the variable that holds your order ID. Pass the value directly. You don’t need to wrap it in an object.
You don’t need to send revenue or other order details. Northbeam gets those from your backend order data.

firePurchaseEvent

The original purchase function. It sends the order ID plus order details like revenue, tax, shipping, and line items. Northbeam only uses the order ID from this event. The other fields aren’t used for reporting, because order details come from your backend. If you’re setting up purchase tracking now, use fireSlimPurchaseEvent instead. If you already use firePurchaseEvent and it works, you don’t need to change it.
id is the only required field. It must exactly match the order_id in the Orders API. For other fields, an empty string ("") or 0 is fine when a value doesn’t apply. Avoid null.
Order fieldsLine item fieldsThese fields go inside each object in lineItems. They can’t be used outside it.

Validation and testing

Open your browser’s Network tab before you complete a test order. The requests can’t be reviewed after the fact. When the event fires correctly, you’ll see two nb-collector requests together:
  1. One with a payload containing data: [{e: "ue",…}]
  2. One with a payload containing data: [{e: "se",…}]. Its se_la value is the order number Northbeam received.
You only see these two requests together when the event is valid. To confirm the event fires only once, refresh the confirmation page with the Network tab open. You should not see a second nb-collector request for the same order number.

Google Tag Manager

If you add the purchase event through Google Tag Manager:
  • Sequence your tags. The Northbeam Pixel tag must fire before the purchase event tag. See Google’s guide to tag sequencing.
  • Use one trigger. Make sure the tag fires on a single event, so it doesn’t fire twice.
  • Publish the container. Unpublished changes don’t track anything.

Final checklist

Before going live, confirm:
  • The purchase event fires on the confirmation page
  • It fires exactly once per order, and refreshing the confirmation page does not fire it again
  • The order ID matches your backend order data exactly
  • The Northbeam Pixel fires first
  • Your Google Tag Manager container is published (if you use it)

Best practices

  • Log success and failure. Wrap the purchase function in code that logs whether it ran. This makes testing much easier.
  • Wait for the pixel. Check that window.Northbeam is ready before calling the function, and retry if it isn’t. This prevents load-order problems.

Example with logging and retry