How-To-Video |

Google Analytics Implementation Documentation

  1. Overview
  2. Using Google Analytics Tracking for Hotel Pages
  3. Using Google Analytics Tracking for Guest Connect
  4. Using Google Analytics with Multiple Hotel Domains
  5. Google Analytics Ecommerce Tracking Code
  6. Link Tagging
  7. Cross-Domain Tracking

DISCLAIMER AND IMPORTANT INFORMATION
The following information is provided with no warranty and PH&R assumes no liability for errors contained in this information or for any potential damages that may result from the usage of this material. This information is provided with the understanding that the user has knowledge of JavaScript as well as properly setting up their own account within Google Analytics. PH&R is unable to troubleshoot Google Analytic implementations beyond the basic information, which is provided below.

OVERVIEW
Due to the ever-increasing number of hotels implementing the popular Google Analytics tool on their websites, there has been a substantial increase in the requests to have this implemented in the Hotel Booking Engine. Unfortunately, not all implementations are equal. Whether it’s the Universal vs. Asynchronous method, various methods and calls, or any other customizable setting, implementing Google Analytics successfully requires an understanding of the process and patience.


There are two versions of Google Analytics that are available for implementation: Universal Analytics and the Google Analytics Asynchronous method. For both methods, there are two main components. The first component is placed in each step of the booking engine and is used to track users’ movements around the system. The second is used to record details of the transaction (reservation) made in the booking engine. Both methods are presented simultaneously in the following, color-coded documentation.

Using Google Analytics Tracking for Hotel Pages
The following are typical basic examples used on the hotel website.

UNIVERSAL ANALYTICS

<script type="text/javascript">
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-XXXXXXXX-X', 'auto', {'allowLinker': true});
ga('require', 'linker'); // Loads the linker plugin for use with ga.js
ga('linker:autoLink', ['synxis.com','phgsecure.com'], false, true);
ga('send', 'pageview');
</script>

 

ASYNCHRONOUS METHOD

<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXX-X']);
_gaq.push(['_setDomainName', '.hoteldomain.com']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_setAllowAnchor', true]);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })();
</script>

Note: The linker plugin and linker:autoLink call in the Universal Analytics example may vary depending on hotel website's implementation and should be used based on the Link Tagging section below

Using Google Analytics Tracking for Hotel Booking Engine

The following are typical basic examples used on the booking engine.

UNIVERSAL ANALYTICS

<script type="text/javascript">
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-XXXXXXXX-X', 'auto', {'allowLinker': true});
ga('require', 'linker');
ga('linker:autoLink', ['hoteldomain.com', 'synxis.com']);
ga('send', 'pageview', '/check-availability');

</script>

 

ASYNCHRONOUS METHOD

<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXX-X']);
_gaq.push(['_setDomainName', '.synxis.com']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_setAllowAnchor', true]);
_gaq.push(['_trackPageview', '/check-availability']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

</script>

This code is placed in every step of the booking process with the exception of the Confirmation and the Teaser pages. The Confirmation page has more extensive tracking that we’ll get into shortly and the Teaser is not used.

Google Analytics code that is provided to the user when setting up their GA account needs to be modified slightly before being implemented. The following is a brief description of each section where modification is either required or optional:

ga('create', 'UA-XXXXXXXX-X', 'auto', {'allowLinker': true});

 

_gaq.push(['_setAccount', 'UA-XXXXXXXX-X']);

The create / _getTracker call is used to store the unique account ID for each profile in your Google Analytics. This ID is provided by Google when creating your account. This field is required and must be correct for the tracking to report properly.

In the Universal Analytics example, 'auto' signifies that the domain name to be used should be automatically determined, i.e. synxis.com for the booking engine and hoteldomain.com for the hotel's website. See the Cross-Domain Tracking section for details.

ga('create', 'UA-XXXXXXXX-X', 'auto', {'allowLinker': true});

 

_gaq.push(['_setAllowLinker', true]);

The allowLinker / _setAllowLinker call is used by Google Analytics to determine whether or not the script should continue to track across multiple domains. This field must be set to true because the booking engine sits on its own domain and not a hotel’s.

ga('send', 'pageview', '/check-availability');

 

_gaq.push(['_trackPageview', '/check-availability']);

This field tells Google Analytics what step of the booking process the user is currently on. Because the booking engine doesn’t use unique URLs for each step of the process, it is important to include this field so Google Analytics can determine these steps and track accordingly. The following list provides the possible values for each step in the process:

Step Value
Check Availability /check-availability
Availability Results /availability-results
Packages /packages
Customer Information /customer-information
Reservation Review (optional step) /reservation-review
Confirmation /confirmation
Search Reservations (to modify/cancel reservations) /search-reservations
Modify Reservations /modify-reservations

Using Google Analytics with Multiple Hotel Domains

It is becoming more and more common for hotels to purchase multiple domains for their website. Purchasing www.hoteldomain.com and www.thehoteldomain.com is a common SEO practice. In this event the tracking code will need to be adjusted slightly. Google Analytics will treat these additional domains as referral traffic unless there is a rule in place telling it these additional domains are also part of the same group and to therefore treat them as internal direct traffic. If a hotel has multiple domains the following steps must be taken.

For Universal Analytics, the referrals must be excluded via the Google Analytics admin panel as described in the documentation.

For Asynchronous Google Analytics, the following code must be added:

_gaq.push(['_addIgnoredRef', '.thehoteldomain.com']);

Google Analytics Ecommerce Tracking Code

Using SynXis tracking tokens, the GA code captures the information about a reservation on the final confirmation/thank-you page. Additional code is required to capture ecommerce data.

<script type="text/javascript">
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-XXXXXXXX-X', 'auto', {'allowLinker': true});
ga('require', 'linker');
ga('linker:autoLink', ['hoteldomain.com', 'synxis.com']);
ga('send', 'pageview', '/confirmation');
ga('require', 'ecommerce', 'ecommerce.js');

ga('ecommerce:addTransaction', {
'id': '%JS_ConfirmNo%',
'affiliation': '%JS_HName%',
'revenue': '%JS_TotalCostWithTax%',
'shipping': '',
'tax': '%JS_Taxes%',
'currency': '%JS_CurrCode%'
});

ga('ecommerce:addItem', {
'id': '%JS_ConfirmNo%',
'name': '%JS_RmTypCd%',
'sku': '%JS_ConfirmNo% - %JS_ArrivalDt%',
'category': '%JS_RateTypCd%',
'price': '%JS_DailyRate%',
'quantity': '%JS_RoomNightsQty%'
});
ga('ecommerce:send');

</script>

 

<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXX-X']);
_gaq.push(['_setDomainName', '.synxis.com']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_setAllowAnchor', true]);
_gaq.push(['_trackPageview', '/confirmation']);
_gaq.push(['_addTrans',

'%JS_ConfirmNo%',
'Web',
'%JS_TotalCost%',
'%JS_Taxes%',
'',
'%JS_CCity%',
'%JS_CState%',
'%JS_CCountry%'
]);

_gaq.push(['_addItem',

'%JS_ConfirmNo%',
'%JS_ConfirmNo% - %JS_ArrivalDt%',
'%JS_HName%',
'%JS_RmTypCd%',
'%JS_DailyRate%',
'%JS_NightsQty%'

]);
_gaq.push(['_set', 'currencyCode', '%JS_CurrCode%']);
_gaq.push(['_trackTrans']); //submits transaction to the Analytics servers

(function() {
var ga = document.createElement('script'); ga.type =
'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') +
'.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(ga, s);
})();

</script>

The following explains what the ecommerce fields do in Google Analytics and the tracking tokens used for each one. These tracking token should not be altered:

%JS_ConfirmNo%
This token grabs the confirmation number of the recent transaction and sends it to Google Analytics. This information can be seen in the Transaction report of Google Analytics.

Example: 26189SY001211

Web
This tells Google Analytics that the transaction occurred on the web store.

%JS_TotalCost%
This token reports the total monetary amount of items bought by the customer. This would include room rates and packages purchased and does not include fees and taxes.

%JS_Taxes%
This token will report the total taxes from the transaction to Google Analytics.

''
This blank field is an optional field for possible shipping costs. In our situation we leave it empty to represent no shipping costs.

%JS_CCity%
This provides the city given by the customer.

%JS_CState%
This provides the state given by the customer.

%JS_CCountry%
This provides the country given by the customer.

These fields are related to the customer details about the transaction/reservation. The following set, being employed in the “addItem” call, are related to the actual item (in our case, a hotel room) that was purchased:

%JS_ConfirmNo%
This token grabs the confirmation number of the recent transaction and sends it to Google Analytics. This information can be seen in the Transaction report of Google Analytics.

Example: 26189SY001211

%JS_ConfirmNo% - %JS_ArrivalDt%
In this field we take two tracking token, the Confirmation Number and the Arrival Date to create a SKU for the transaction. This information can be found in the Product SKU report found under Product Performance in Google Analytics.

Example: 26189SY001211 - 4/14/2011

%JS_HName%
This reports the name of the hotel to Google Analytics.

%JS_RmTypCd%
This token reports to Google Analytics the room type code. Examples could be DLXK for deluxe king. This information can be found in the Categories report found under Product Performance in Google Analytics.

Example: STK

%JS_DailyRate%
This reports to Google Analytics the daily rate of the room. This information is important because Google Analytics uses this value to calculate average revenue and product revenue for each category and product tracked by Google Analytics.

%JS_NightsQty%
This reports to Google Analytics the total number of days booked for a given room. This information is important because Google Analytics uses this value along with the Daily Rate to calculate revenue amounts and averages.

In addition to the GA implementation in the booking engine, a hotel also needs to properly implement Google Analytics on their own site if they haven’t done so already. Outbound links to the booking engine, widgets, and specific javascript calls in GA need to be programmed correctly.

Link Tagging

All outbound links to the booking engine need to be tagged with a specific piece of code that tells Google to continue tracking the current user’s activity once they leave a hotel’s website. The methods for Universal Analytics and Asynchronous Google Analytics differ.

Universal Analytics
For Universal Analytics, the Auto Linking plugin may be used to automatically implement cross domain linking across all the links on a page. This is called via the following two lines (which are included in the above examples).

ga('require', 'linker'); // Loads the linker plugin for use with ga.js
ga('linker:autoLink', ['synxis.com','phgsecure.com'], false, true);

Please note, as noted in the official documentation, Google advises that this method may not work on all websites. If this is the case, then alternate methods of link tagging (also called "decorating") may be pursued as noted in the Cross-Domain Tracking documentation.

Asynchronous Google Analytics
For Asynchronous Google Analytics, links to the booking engine must be tagged as follows.

<a href="https://www.phgsecure.com/IBE/bookingRedirect.ashx?propertyCode=BCTS4" target="_blank"
onclick="_gaq.push(['_link',
'https://www.phgsecure.com/IBE/bookingRedirect.ashx?propertyCode=BCTS4']);
return false;">Lorem Ipsum‹/a›

Forms (primarily booking widgets) also need to be tagged appropriately:

<form name="f" method="post" onsubmit="_gaq.push(['_linkByPost', this]);">

Note: If the form method is GET and not POST then linkByPost changes slightly as seen below:

<form name="f" method="get" onsubmit="_gaq.push(['_linkByPost', this, true]);">

Please see the official documentation on these functions for more information.

Cross-domain Tracking

One of the most important issues with the implementation of Google Analytics for any of our hotels is that of setting up cross-domain tracking. If this is not set up properly then the tracking session might be lost or start over which would create duplicate values, might be ignored completely (which would drop tracking), and/or might cause issues with referrals and other tracking properties. It is very important to set up the cross-domain tracking correctly. In order for cross domain tracking to work, the following steps must be taken.

  1. On the booking engine, for Universal Analytics, the domain used in the inital 'create' call must be set to 'auto' or 'synxis.com'. For the Asynchronous method, the setDomainName() call should be set to '.synxis.com'. AllowLinker must be set to true for both. See the above section on Google Analytics for Hotel Booking Engine for examples.
  2. On the hotel website, for Universal Analytics, the domain used in the inital 'create' call must be set to 'auto' or 'hoteldomain.com' where hoteldomain.com is the hotel's website domain. For the Asynchronous method, the setDomainName() call should be set to '.hotelname.com'. AllowLinker must be set to true for both. See the above section on Google Analytics for Hotel Pages for examples.
  3. On the hotel website, all links to the booking engine must be tagged/decorated. See the above section on link tagging for details.

This has been discussed in great detail on the Google Analytics documentation well as based on calls to Sabre about the proper implementation of Google Analytics with the booking engine.

Referrals from other websites

Some hotels may note referrals from other websites or even competitors. This is normal. Google tracks the path of visitors across multiple websites. If a guest views a competitor site which is also using Google Analytics before making a booking at your hotel, Google may recognize this as a referral.