How to Implement Audiohook tracking on purchases on Shopify
Shopify has sandboxed their custom events for tracking purchases, making some changes to how the Audiohook tag needs to be added for purchase events
Step 1: Log in to Shopify Admin
- Go to your Shopify store admin.
- From the left menu, navigate to Settings β Customer Events.

Step 2: Create a New Custom Event
- Click Add custom pixel.
- Give it a clear name, such as:
Audiohook Purchase Event

Step 3: Paste in the Code
- Copy the following code block.
- Paste it into the pixel editor:
// Load Audiohook pixel inside Shopify's Customer Events sandbox
(function loadAudiohook(callback) {
const script = document.createElement("script");
script.src = "https://js.audiohook.com/analytics.js?audiohookId=YOUR_AUDIOHOOK_ID";
script.onload = callback;
script.onerror = () => console.warn("Failed to load Audiohook analytics.js");
document.head.appendChild(script);
})(function onAudiohookReady() {
// PURCHASE event
analytics.subscribe("checkout_completed", (event) => {
if (typeof window.ahTrack === "function") {
const checkout = event.data.checkout;
window.ahTrack("purchase", {
value: checkout.totalPrice.amount,
currency: checkout.currencyCode,
order_id: checkout.order.id,
email: checkout.email
});
}
});
// INITIATE CHECKOUT
analytics.subscribe("checkout_started", (event) => {
if (typeof window.ahTrack === "function") {
const checkout = event.data.checkout;
window.ahTrack("initiate_checkout", {
value: checkout.totalPrice.amount,
currency: checkout.currencyCode,
email: checkout.email
});
}
});
});
Step 4: Swap the Audiohook ID
In the code above, replace:
YOUR_AUDIOHOOK_ID
with your unique Audiohook Pixel ID.
Example:
https://js.audiohook.com/analytics.js?audiohookId=a97cc759-0f29-4c24-8287-55a115dca83b
Step 5: Save and Test
- Click Save in the Shopify editor.
- Click Connect to verify the pixel is working.

Did this answer your question?
π
π
π€©