Integration Guide
One universal snippet for both your hotel website and Avvio booking engine.
Quick Start Script Tag
Add this snippet to every page — hotel website and booking engine — before the closing </body> tag:
<script src="https://cdn.achooo.io/v1/achooo.min.js"></script>
<script>
(function() {
var achooo = Achooo.createAchooo({
hotelId: 'YOUR_HOTEL_ID', // e.g. 'htl_kR7mNx9pQ2wS'
ingestEndpoint: 'https://api.achooo.io',
handoffEndpoint: 'https://handoff.achooo.io',
adapterAutoDetect: true
});
achooo.init();
window.achooo = achooo; // expose for optional manual tracking
})();
</script>
The IIFE bundle exposes a global Achooo object with a createAchooo factory function. Setting adapterAutoDetect: true is safe on all pages.
NPM Installation NPM
npm install @achooo/sdk
import { createAchooo } from '@achooo/sdk';
const achooo = createAchooo({
hotelId: 'htl_kR7mNx9pQ2wS',
ingestEndpoint: 'https://api.achooo.io',
handoffEndpoint: 'https://handoff.achooo.io',
adapterAutoDetect: true,
});
achooo.init();
Configuration Reference
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
hotelId | string | Yes | - | Opaque hotel identifier (provided by Achooo, e.g. htl_kR7mNx9pQ2wS) |
ingestEndpoint | string | Yes | - | Events ingestion service URL |
handoffEndpoint | string | Yes | - | Cross-domain identity handoff service URL |
apiKey | string | No | null | API key for ingest authentication (provided by Achooo) |
debug | boolean | No | false | Enable verbose console logging for SDK and adapter activity |
batchSize | number | No | 25 | Number of events to buffer before flushing |
flushIntervalMs | number | No | 5000 | Periodic flush interval in milliseconds |
sessionTimeoutMs | number | No | 1800000 | Session expiry duration (default: 30 min) |
adapterAutoDetect | boolean | No | true | Auto-detect the booking engine adapter |
adapterName | string | No | null | Force a specific adapter (e.g., "avvio") |
bookingEngineDomain | string | No | null | Explicit booking engine hostname for guaranteed cross-domain handoff (e.g., secure.yourhotel.com) |
hashSalt | string | No | hotelId | Per-hotel salt for surname hashing (privacy) |
Dynamic Hotel ID
Each hotel property has a unique opaque hotelId assigned by Achooo (e.g. htl_kR7mNx9pQ2wS). If you manage multiple properties, set it dynamically from your per-hotel configuration:
(function() {
var achooo = Achooo.createAchooo({
hotelId: window.HOTEL_CONFIG.achoooHotelId,
ingestEndpoint: 'https://api.achooo.io',
handoffEndpoint: 'https://handoff.achooo.io',
adapterAutoDetect: true
});
achooo.init();
window.achooo = achooo;
})();
If you inject configuration server-side, you can also template the hotel ID directly:
(function() {
var achooo = Achooo.createAchooo({
hotelId: '{{hotel.achooo_id}}',
ingestEndpoint: 'https://api.achooo.io',
handoffEndpoint: 'https://handoff.achooo.io',
adapterAutoDetect: true
});
achooo.init();
window.achooo = achooo;
})();
How the Adapter Works
The Achooo SDK includes a built-in Avvio adapter that automatically detects when it's running on an Avvio booking engine page. On non-Avvio pages (hotel website), the detection is a fast synchronous check that immediately skips — no performance cost, no errors, no extra network calls.
Auto-Detection
The adapter uses a scoring system to detect Avvio pages:
- Hostname patterns — domains containing
.avvio.,booking.*.com,reservations*. - DOM signatures — elements like
.avvio-booking,.avvio-widget,[data-avvio],script[src*="avvio"] - Window globals — objects like
avvioBooking,AvvioWidget,__AVVIO__
init(). You can force the adapter with adapterName: "avvio" if auto-detection doesn't activate on a non-standard page.Capture Strategy
- Network interception (preferred) — Intercepts
fetch()andXMLHttpRequestcalls to Avvio API endpoints. Captures the richest data directly from API payloads. - DOM observation (fallback) — Watches for booking confirmation elements in the DOM if network interception doesn't capture expected events.
API Patterns Monitored
| Category | URL Patterns |
|---|---|
| Availability / Search | /api/availability, /search, /rates, /checkavailability |
| Booking | /api/booking, /reservation, /confirm |
| Cancellation | /api/cancel, /cancellation |
Cross-Domain Handoff
When a guest navigates from a hotel website to the Avvio booking engine, the SDK stitches the session across domains:
- Hotel website SDK calls
/handoff/mintto get a signed token containing the guest's anonymous identity - The token is appended to the booking engine URL as a query parameter
- Booking engine SDK calls
/handoff/consumeto recover the stitched identity - The guest's journey is tracked as a single continuous session
hotelId.Events Captured
The Avvio adapter automatically captures these events:
| Event | Trigger | Key Data |
|---|---|---|
page_view | Every page load | URL, referrer, title |
page_dwell | Page unload | Time spent on page |
date_search | Availability search | Check-in/out dates, guests, rooms |
rate_quote | Rate displayed to guest | Room type, rate plan, amount, currency |
funnel_step | Booking funnel progression | Step name, step number, time on previous step |
booking_created | Booking confirmed | Confirmation number, surname (hashed), dates, amount |
booking_cancelled | Booking cancelled | Confirmation number, surname (hashed), reason |
booking_modified | Booking modified | Modification type, original vs new values |
All surname data is hashed with PBKDF2 using the per-hotel salt before transmission. No PII is stored.
Testing & Verification
Enable Debug Mode
Set debug: true in the SDK config to enable verbose console logging:
(function() {
var achooo = Achooo.createAchooo({
hotelId: 'htl_kR7mNx9pQ2wS',
ingestEndpoint: 'https://api.achooo.io',
handoffEndpoint: 'https://handoff.achooo.io',
adapterAutoDetect: true,
debug: true
});
achooo.init();
window.achooo = achooo;
})();
With debug mode on, you'll see console output for:
- SDK initialization and configuration
- Adapter detection results (score, confidence level)
- Network interception activity (matched API calls)
- Events captured and batched
- Flush/send activity to the ingest endpoint
Adapter Health Check
After initialization, check the adapter's health status in the browser console:
console.log(achooo.getAdapterHealth());
// { status: 'healthy', confidence: 'HIGH', capturedEvents: 5, lastCaptureAt: '...', issues: [] }
Health statuses:
- healthy — Adapter detected and capturing events normally
- degraded — Adapter active but some capture methods unavailable
- unhealthy — Adapter failed to initialize or capture events
Network Inspection
Open browser DevTools (Network tab) and look for requests to:
POST /ingest— Event batches sent to the Achooo ingestion servicePOST /handoff/mint— Identity token creation (hotel website side)POST /handoff/consume— Identity token consumption (booking engine side)
Verify the Script Loaded
// In the browser console:
console.log(typeof Achooo.createAchooo); // "function"
Troubleshooting
| Symptom | Likely Cause | Solution |
|---|---|---|
Achooo is not defined | Script failed to load | Check the script URL, network tab for 404s |
| Adapter not detected | Non-standard Avvio page | Set adapterName: "avvio" to force activation |
| No events in dashboard | Wrong hotelId or ingestEndpoint | Verify config values, check debug console output |
| Cross-domain handoff failing | Mismatched hotelId between sites | Ensure both sites use the same hotelId |
| Events not captured | Ad blocker or CSP blocking | Check for blocked network requests in DevTools |