> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hiveinspect.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Track Online Bookings in Google, Meta and Other Ad Tools

> Count each online booking in Google Analytics, Google Ads, Meta, Reddit and ChatGPT ads with one line of code on the website that embeds your Hive widget.

In the dashboard: **Business Tools → Widget Integration → Track bookings in your ads**

Your booking form runs inside a frame from Hive, so the ad tags on your website can't see what happens in it. Add one line of code to your website, and each booking is sent to the ad tags you already have. You can then see which ads bring in bookings.

> [!NOTE]
>
> **This only works when the widget is embedded on your own website.** Bookings from your plain link, QR code or public page aren't counted, because your ad tags aren't on those pages. To track an ad, send it to a page of your website that has the widget on it.

## What counts as a booking

A booking counts once, when the client clicks **Confirm Inspection** and the inspection moves to **Waiting**.

| What happens | Inspection status | Counted? |
| - | - | - |
| The client fills in the form but doesn't pick a time | Draft | No |
| **The client picks a time and clicks Confirm Inspection** | **Waiting** | **Yes** |
| You confirm the inspection | Confirmed | No. To act on this, use the [`inspection.confirmed` webhook](https://docs.hiveinspect.com/api/webhook-events). |

## Add the tracking code

### 1. Copy the code

Go to **Business Tools → Widget Integration**. Under **Track bookings in your ads**, click the copy button.

![The Track bookings in your ads card on the Widget Integration page. It explains that bookings count when the client clicks Confirm Inspection and that it only works when the widget is embedded on your own website. Below is one line of tracking code with a copy button, and a Read the setup guide button](https://mintcdn.com/hiveinspect-43c85ed1/26Qse1tEglT1qqV-/images/how-tos/track-online-bookings-card.png?fit=max\&auto=format\&n=26Qse1tEglT1qqV-\&q=85\&s=fb91dca0fa673777ac96a40ff50847ae)

```html theme={"theme":{"light":"github-light","dark":"vesper"}}
<script src="https://dashboard.hiveinspect.com/hive-scheduler.js?v=1" async></script>
```

### 2. Add it to your website

Paste it where your website's Google tag or other ad tags are added. This is usually a site-wide **header code** or **custom code** setting. It also works on just the page that has the widget.

> [!WARNING]
>
> Don't paste it into the same HTML block as the widget. Wix and some other website builders put those blocks in a frame of their own, where your ad tags can't be reached.

### 3. Set up your ad tools

Follow the steps for each tool below, then [test it](#test-your-setup).

## Set up your ad tools

The code uses the ad tags already on your website. It doesn't add any. If a tag isn't on the page, that tool is skipped.

| Ad tool | What gets sent | What you do |
| - | - | - |
| Google Analytics 4 | `generate_lead` | Mark it as a key event |
| Google Ads | See below | Choose one of the two options |
| Meta (Facebook and Instagram) | `Schedule` | Choose **Schedule** as the conversion event for your campaign |
| Reddit | `Lead` | Choose **Lead** as the conversion event for your campaign |
| ChatGPT ads | `appointment_scheduled` | Choose it as the conversion event for your campaign |

### Google Analytics 4

1. Make a test booking so Google Analytics receives `generate_lead`.
2. In Google Analytics, open **Admin** and find the list of events.
3. Mark `generate_lead` as a **key event**.

### Google Ads

Use **one** of these options, not both. Using both counts each booking twice.

**Option 1: import from Google Analytics.** This is the simplest option if your Google Ads and Google Analytics accounts are linked. Mark `generate_lead` as a key event, then in Google Ads create a new conversion action and import it from Google Analytics.

**Option 2: use a Google Ads conversion directly.** Create a conversion action in Google Ads for your website, and copy its conversion ID and label. Add them to the tracking code:

```html theme={"theme":{"light":"github-light","dark":"vesper"}}
<script src="https://dashboard.hiveinspect.com/hive-scheduler.js?v=1" data-google-ads="AW-123456789/AbCdEfGhIj" async></script>
```

Your website must already have the Google tag on it for this to work.

### Google Tag Manager

If Tag Manager runs your ad tags, have Tag Manager fire them, and turn off the automatic sending. Otherwise each booking is counted twice.

1. Add the tracking code with `data-auto="false"`:

   ```html theme={"theme":{"light":"github-light","dark":"vesper"}}
   <script src="https://dashboard.hiveinspect.com/hive-scheduler.js?v=1" data-auto="false" async></script>
   ```

2. Create a **Custom Event** trigger named `hive_booking_requested`.

3. Fire your tags from that trigger. These Data Layer Variables are available:

| Variable | What it holds |
| - | - |
| `hive_booking_ref` | A reference for this booking. Use it as the event or transaction ID to drop duplicates. |
| `hive_value` | The booking total. Missing if it isn't known. |
| `hive_currency` | `USD` or `CAD`. Missing if the total isn't known. |

## What is sent

* **The booking total**, including sales tax and any date or time fees, as saved with the booking. It's sent even if **Show Pricing on Online Scheduler** is off. You can still change the price before you confirm, and the ad tool isn't told about that change.
* **The currency.**
* **A booking reference.** It isn't the inspection number, and it can't be used to look up the booking.

The client's name, email, phone and address are never sent. Cookie and privacy settings stay with your website, because the code only uses tags you already run.

## Test your setup

A test booking is a real booking, and you get the usual emails and texts. Use your own details, and [delete the inspection](https://docs.hiveinspect.com/how-tos/delete-inspection.md) afterwards.

1. Open the page of your website that has the widget. Use your real website, not the **Preview** button.
2. Complete a booking, right through **Confirm Inspection**, until you see **Thank You!**.
3. Check that it arrived:
   * **Google Analytics:** look for `generate_lead` in **Reports → Realtime**.
   * **Google Ads or Tag Manager:** use [Google Tag Assistant](https://tagassistant.google.com/).
   * **Meta:** use **Test Events** in Events Manager.
   * **Reddit and ChatGPT ads:** check the event in that tool's ads manager.

New events can take a day to show up in standard reports. An ad blocker can stop a tag from firing, so test in a browser without one.

## For web developers

Without the tracking code, you can listen for the message yourself. Your code must run on the top-level page. Always check the origin.

```js theme={"theme":{"light":"github-light","dark":"vesper"}}
window.addEventListener('message', function (event) {
  if (event.origin !== 'https://dashboard.hiveinspect.com') return;
  if (!event.data || event.data.type !== 'hive:booking_requested') return;

  // event.data.bookingRef, event.data.value, event.data.currency
});
```

| Field | Type | Notes |
| - | - | - |
| `type` | string | Always `hive:booking_requested` |
| `bookingRef` | string | Starts with `hb_`. The same booking always has the same reference. Use it to drop duplicates. |
| `value` | number | The booking total, such as `475.5`. Left out if it isn't known or is 0. |
| `currency` | string | `USD` or `CAD`. Left out when `value` is. |

There's no separate message for the first part of the form, and the message doesn't include which services were booked. Your page must keep the widget in the frame. If it opens the date and time page outside the frame, the message can't reach your page.

## Common questions

**Nothing shows up after a test booking.** Check that:

* the widget is embedded on the page, and you didn't use a direct link or the **Preview** button;
* you reached **Thank You!**;
* the tracking code is on the page: open your browser's developer tools and look for `hive-scheduler.js` in the **Network** tab;
* your ad tag is on the same page as the widget;
* the tracking code isn't inside the same HTML block as the widget.

**Each booking is counted twice.** You probably have two setups firing, such as a Google Analytics import and `data-google-ads`, or Tag Manager without `data-auto="false"`. Keep one.

**Can I track quotes sent by email?** No. When a client picks a time from a quote you sent, they aren't on your website, so your ad tags aren't there. Only bookings made in the widget on your website are counted.

**Does the quote widget count?** Yes, if it's embedded. A client who clicks **Ready to Schedule?** continues into the scheduling widget, and the booking counts when they click **Confirm Inspection**. Getting a price on its own doesn't count.

**Can I track other ad tools?** Yes. Use [Google Tag Manager](#google-tag-manager) or the [message for web developers](#for-web-developers) to send the booking to any tool.

## Where to go next

* [Add the scheduling widget to your website](https://docs.hiveinspect.com/how-tos/scheduling-widget.md): your embed code, and every scheduler setting.
* [Add the instant quote widget](https://docs.hiveinspect.com/how-tos/quote-widget.md): show a price first, then continue to book.
* [Webhook events](https://docs.hiveinspect.com/api/webhook-events.md): get told when an inspection is confirmed, paid or completed.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.