How to Track OnceHub Bookings with Google Tag Manager

9 May, 2026

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>
JavaScript

This 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

  1. In Google Tag Manager, go to Tags → New
  2. Select Custom HTML
  3. Paste the code above
  4. Name it “OnceHub – Booking Listener”

Step 2: Set Trigger to All Pages

  1. Click Triggering
  2. Select All Pages
  3. Save the tag

Step 3: Create a Custom Event Trigger

  1. Go to Triggers → New
  2. Choose Custom Event
  3. Enter oncehub_booking_completed as the event name
  4. Name it “OnceHub – Booking Complete”
  5. 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 ID
  • customer_name → Customer’s name
  • customer_email → Customer’s email
  • customer_phone → Customer’s phone number
  • event_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.__oncehubBooked flag to prevent duplicate events
  • Pushes booking details to dataLayer

Testing

  1. Enable GTM Preview Mode
  2. Complete a test booking on your OnceHub form
  3. Check that oncehub_booking_completed appears in the dataLayer
  4. Verify your conversion tags fire
  5. 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.

Related Posts

How to Track WPForms Submissions with Google Tag Manager

How to Track WPForms Submissions with Google Tag Manager

If you're using WPForms on your WordPress site and want to track form submissions as conversions, here's an event listener that handles both Ajax and non-Ajax forms. What This Does WPForms can submit forms in two ways — with Ajax (no page reload) and without. Most...

read more

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Shibbir Ahmed

Hi, I’m here to help you learn Google Tag Manager and Google Analytics. Join thousands of other digital marketers and digital analysts in this exciting journey.
Book Meeting

Search Tags

Claim FREE Audit