Operations | May 13, 2026 | 4 min read
Tracking ReservationKey Bookings as GA4 Ecommerce Purchases
Connect your ReservationKey booking engine to Google Analytics 4 ecommerce tracking so completed bookings can appear as purchase events with revenue, transaction IDs, unit details, and marketing attribution.
If you want to track which marketing channels are actually generating bookings and revenue in Google Analytics 4, you can connect your ReservationKey booking engine to GA4 ecommerce tracking using ReservationKey's built-in data layer.
This guide walks through a working setup that supports:
- Revenue attribution in GA4
- Cross-domain tracking between your website and ReservationKey booking pages
- Ecommerce
purchaseevents - Tracking by room, cottage, cabin, or unit
- Attribution from sources like Facebook, Instagram, TripAdvisor, Google Search, and more
Special thanks to ReservationKey customer Paul from Kauai Cottages for helping test and refine this approach.
How the Tracking Works
The setup uses two pieces:
- A GA4 tracking script loaded on every ReservationKey booking page
- A purchase event script that runs only on the final confirmation page
The purchase event reads booking details from:
window.reservationData
This object contains reservation information such as:
- Reservation ID
- Payment amount
- Taxes
- Room/unit ID
- Check-in/check-out dates
- Guest count
- Page alias
This data is available reliably on the final confirmation page. See this blog post for complete data layer specifications.
Important: Do Not Use ReservationKey Merge Codes for GA4 Ecommerce Tracking
Some users initially try using ReservationKey email merge codes such as:
{{CONFIRMNUM}}
{{TOTALPRICE}}
{{ROOMNAME}}
However, these merge codes are designed for ReservationKey email templates, not JavaScript ecommerce tracking.
Instead, always use:
window.reservationData
Step 1 - Add the GA4 Script to Code on Every Page
In ReservationKey, go to:
Website -> Reservation Pages -> Edit -> Settings -> Settings 2
Paste this into:
Code on EVERY page
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){
dataLayer.push(arguments);
}
gtag('js', new Date());
gtag('config', 'G-XXXXXXXXXX', {
'linker': {
'domains': [
'yourwebsite.com',
'v2.reservationkey.com'
],
'accept_incoming': true
}
});
</script>
Replace:
G-XXXXXXXXXXwith your GA4 Measurement IDyourwebsite.comwith your own domain name
Step 2 - Enable Cross-Domain Tracking in GA4
Inside Google Analytics 4, go to:
Admin -> Data Streams -> Your Web Stream
Then:
Configure tag settings -> Configure your domains
Add:
yourwebsite.comv2.reservationkey.com
This allows GA4 to preserve the original traffic source when visitors move between your website and ReservationKey booking pages.
Without this step, bookings may appear as:
referral / v2.reservationkey.com
instead of the original source, such as:
- Google organic
- TripAdvisor
- Email campaigns
Step 3 - Add the Purchase Tracking Script
In ReservationKey, go to:
Website -> Reservation Pages -> Edit -> Settings -> Settings 2
Paste this into:
Code ONLY on final confirmation page
Example GA4 Purchase Tracking Script
This example tracks:
- Transaction ID
- Revenue
- Taxes
- Unit name
- Unit ID
- Ecommerce purchase event
<script>
/* ReservationKey GA4 Purchase Tracking */
(function(){
if(window._rkPurchaseFired) return;
window.dataLayer = window.dataLayer || [];
function gtag(){
dataLayer.push(arguments);
}
var rd = window.reservationData;
if(!rd || !rd.id_reservation){
console.log("[RK] No reservationData");
return;
}
var txnId = rd.id_reservation;
var value = parseFloat(rd.payments) || 0;
var tax = parseFloat(rd.taxes) || 0;
var roomPrice = parseFloat(rd.total_room_price) || 0;
/* Map ReservationKey room IDs to names; ID numbers are in the bottom right corner room settings pages */
var unitMap = {
"3099":"Ohana",
"3101":"River",
"3102":"Garden"
};
function resolveRoom(){
var id = String(
rd.id_room ||
rd.idRoom ||
rd.id_unit ||
""
);
return unitMap[id] || rd.page_alias || "Direct Booking";
}
function fire(){
if(window._rkPurchaseFired) return;
window._rkPurchaseFired = true;
var itemName = resolveRoom();
gtag("event", "purchase", {
transaction_id: txnId,
value: value,
currency: "USD",
tax: tax,
items: [{
item_id: String(rd.id_room || txnId),
item_name: itemName,
item_category: "rental",
price: roomPrice,
quantity: 1
}]
});
console.log("[RK PURCHASE]", {
txnId: txnId,
value: value,
room: itemName
});
}
fire();
})();
</script>
Understanding window.reservationData
The ReservationKey booking engine exposes reservation information through:
window.reservationData
Some useful fields include:
| Field | Description |
|---|---|
id_reservation | Reservation confirmation number / transaction ID |
payments | Total payment amount |
taxes | Tax amount |
total_room_price | Room price before taxes/fees |
id_room | Room or unit ID |
page_alias | Booking page alias |
You can inspect this object in your browser console:
console.log(window.reservationData)
Testing Your Setup
After placing a test booking:
- Open Browser Developer Tools.
- Check the console for messages like
[RK PURCHASE]. - In GA4, go to
Reports -> Realtime.
You should see:
- A purchase event
- Revenue values
- Transaction IDs
- Item names
Recommended Approach
For most ReservationKey customers, the best setup is:
- Use GA4 with cross-domain tracking
- Use
window.reservationData - Track purchases using ecommerce events
- Map your room IDs to readable unit names
This gives you much better visibility into:
- Which marketing channels generate bookings
- Revenue attribution
- Conversion tracking
- Return on ad spend