If you’re using OnceHub (formerly ScheduleOnce) for appointment scheduling and want to track completed bookings as conversions in Google Analytics, Facebook Ads, or other platforms, here’s a simple event listener to set it up.
The OnceHub Event Listener Code
javascript
<script>
window.__oncehubBooked = false;
window.addEventListener('message', function(e) {
if (e.origin !== 'https://go.oncehub.com') return;
if (
!e.data ||
!e.data.bookingData ||
!e.data.bookingData.bookingInfo
) return;
if (window.__oncehubBooked) return;
window.__oncehubBooked = true;
var b = e.data.bookingData.bookingInfo;
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
event: 'oncehub_booking_completed',
booking_id: b.BookingId ? b.BookingId[0] : '',
customer_name: b.CustomerName || '',
customer_email: b.CustomerEmail || '',
customer_phone: b.CustomerMobile || b.CustomerPhone || '',
event_type: b.EventTypeName || ''
});
});
</script>JavaScriptThis captures the oncehub_booking_completed event along with booking details like customer name, email, phone, and booking ID.
Setup in GTM
Step 1: Create a Custom HTML Tag
- In Google Tag Manager, go to Tags → New
- Select Custom HTML
- Paste the code above
- Name it “OnceHub – Booking Listener”
Step 2: Set Trigger to All Pages
- Click Triggering
- Select All Pages
- Save the tag
Step 3: Create a Custom Event Trigger
- Go to Triggers → New
- Choose Custom Event
- Enter
oncehub_booking_completedas the event name - Name it “OnceHub – Booking Complete”
- Save
Step 4: Fire Your Conversion Tags
Use this trigger on your marketing tags:
- Google Analytics 4: Create GA4 Event with event name “booking_complete”
- Facebook Pixel: Add to your Lead or Schedule event
- Google Ads: Add to conversion tracking
Accessing Booking Data
The listener captures valuable booking details. To use them, create Data Layer Variables:
booking_id→ Unique booking IDcustomer_name→ Customer’s namecustomer_email→ Customer’s emailcustomer_phone→ Customer’s phone numberevent_type→ Type of appointment booked
Go to Variables → New → Data Layer Variable and enter the variable name to use this data in your tags.
How It Works
The code listens for messages from OnceHub:
- Verifies the message is from
https://go.oncehub.com(security check) - Checks for valid booking data
- Uses
window.__oncehubBookedflag to prevent duplicate events - Pushes booking details to dataLayer
Testing
- Enable GTM Preview Mode
- Complete a test booking on your OnceHub form
- Check that
oncehub_booking_completedappears in the dataLayer - Verify your conversion tags fire
- Publish once confirmed
Privacy Tips
When tracking booking data:
- Only fire tags with proper user consent
- Be mindful of capturing personal information like email and phone
- Update your privacy policy to mention booking tracking
- Consider which fields you actually need
That’s it. Once published, you’ll start tracking OnceHub bookings as conversions across all your marketing platforms.



0 Comments