New Data Layer Makes it Easy to Add Reservation Data to Tracking Code

July 21, 2025

By

John

As our users increasingly rely on third-party tracking and marketing tools like Sojern, Google Ads, and Meta Pixel, we wanted to make it easier to integrate ReservationKey reservation data without requiring our clients to do a lot of extra work. This blog post walks through how we created a centralized reservationData layer that can be used in any tracking snippet, and how developers can take advantage of it.

Why We Built a Data Layer

Previously, integrating third-party marketing tags meant asking each client to manually customize their tracking code with data pulled from our system. This led to mistakes, inconsistent formats (especially for dates), and a lot of support questions.

Now, our new window.reservationData object solves this by:

  • Centralizing all the reservation-related data in one place
  • Ensuring consistent formatting (e.g. ISO 8601 date format)
  • Including a SHA-256 hash of the guest email
  • Making it easy to extend in the future

What the Data Layer Looks Like

Here is an example of what the reservationData object looks like:

window.reservationData = {
  checkin: '2025-10-19',
  checkout: '2025-10-22',
  id_reservation: '11009773',
  page_id: '65585',
  page_alias: 'reservations',
  check_in_time: '6:30pm',
  guest_first_name: 'john',
  guest_last_name: 'thompson',
  guest_first_name2: 'mike',
  guest_last_name2: 'smith`',
  total_room_price: '864',
  discounts: '0',
  fees: '0',
  items_for_sale: '0',
  expenses: '0',
  taxes: '138.24',
  payments: '0',
  guest_email: 'john@reservationkey.com',
  guest_email_hash_sha256: 'b3375bf43243fef0755eb54f6924c4dc8ca2a21affcff6999cd9a17b8ee89a17',
  guest_address: '123 Sansome street, san francisco ca',
  guest_city: '',
  guest_state: '',
  guest_zip: '',
  guest_country: '',
  guest_phone: '415.800.4905',
  guest_business_phone: '',
  guest_mobile_phone: '',
  contact_notes: '',
  guest_company: '',
  num_adults: '4',
  num_children: '0',
  num_rooms: '2'
};

All values are generated server-side, including the email hash. Dates are also converted to ISO format (yyyy-mm-dd) server-side to avoid needing any client-side processing.

Adding the Data to Tracking Snippets

Instead of hardcoding values into each third-party tag, clients (or we) can now just reference the variables:

<script>
  var data = window.reservationData;

  sojern_trackers.push({
    cid: 'your-sojern-id',
    email_hash: data.emailHash,
    checkin_date: data.check_in,
    checkout_date: data.check_out,
    revenue: data.roomRevenue,
    currency: data.currency
  });
</script>

You can add your tracking code into a website message (such as the confirmation message) or into the tracking code field we have specially set up for this in the reservation page settings.

Tracking code field in Reservation Page settings:

No need to worry about parsing dates or hashing email addresses. It's already done.

Benefits to Clients and Us

  • Clients: Easier setup, fewer support requests, and faster onboarding with third-party tools.
  • Us: We control the format, logic, and timing, reducing mistakes and debugging time.

What’s Next

We plan to expand the data layer to include:

  • Booking source
  • Length of stay
  • Custom tags

And possibly provide a debug mode to log the reservationData to the console for easier development.

If you're using ReservationKey and want to start taking advantage of this system, reach out and we can help implement it. The goal is to make tracking painless, accurate, and automatic.