How to Use Google Analytics to Track Goals Through Checkout

Home > Analytics > How to Use Google Analytics to Track Goals Through Checkout

If you’ve experimented with Google Analytics, you probably know you can set up and track Goals with it, but two things can make it challenging – (1) how to track goals from your site through the booking process, which usually takes place on a website managed by your booking software company, and (2) how to set up your goals so they are useful. Just to add to the confusion, Google has recently updated Analytics, changing the way you track from your site to the booking engine.

In this post, we’ll look at the way to install the Google Analytics (GA) code, and how to set up your goals to track your bookings.

Overview of Tracking from Your Site to the Booking Engine

If you don’t care how it works, you can just skip to the next section to begin putting it together.

Google has changed the way you track visitors who go from your website to your booking engine.

When you have GA tracking code on your site, it creates a cookie to track a visitor, storing bits of information, like the way they arrived at your site, the time they arrived, and the path they take through your site. Normally these cookies do not allow other sites to read them. As a result, when the visitor goes to your booking engine, the tracking code sees it as another site, and the booking engine cannot read the cookie from your site. This means your Analytics will not show the source of the booking as being from the true referring source, but will show it as coming from your site.

In order to track the visitor through your site, to the booking system (and potentially back to your site again), you must set up the tracking code to allow the booking engine to be considered as if it was part of your site, and read the cookie even though it is technically another site.

Setting Up Tracking to Include Your Booking Engine

Previously Google had recommended using a line of code to tell GA to consider the two sites (yours and the booking engine) to both have access to the tracking cookie by setting the domain to “none”. GA has changed this, so that setting the domain name to “none” will now prevent a sub-domain (if the primary domain is www.abouttheinn.com, an example of a subdomain would be blog.abouttheinn.com) from accessing the cookie from the primary domain, unless you explicitly permit it. Consequently, you’ll want to use the newer approach.

1. Modify the GA code for your website

Basic GA tracking code for your website will look something like this (with the XXXXX-X section changed to reflect your GA ID):

<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-X']);
_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>

Don’t worry about the details, but if you’re interested a full explanation is in the GA Help documents.

In order to track the cookie from your site over to the booking engine site, you’ll want to modify a portion of your tracking code on your website to look like:

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-X']);
_gaq.push(['_setDomainName', 'YOURWEBSITE.com']);
_gaq.push(['_setAllowLinker', true]);

Then wherever you link to your booking engine, it needs the link code:

<a href="https://www.BOOKINGENGINE.com/AVAILABILITY.html"
onclick="_gaq.push(['_link', 'https://www.BOOKINGENGINE.com/AVAILABILITY.html']); return false;">Book Now</a>

There are basically two things you are changing. First, after the setAccount line, you add a line (setDomainName) to specify the domain name as your site, then add another line (setAllowLinker) to permit linking to another site. Second, wherever you link to the other site, you add the “onclick” JavaScript to pass the cookie to the site named (BOOKINGENGINE.com).

The first part gives permission to pass the cookie with a link. The second actually does it.

2. Modify the code on your booking engine

Some booking engines (notably the RezOvation GT booking engine, ResNexus, and probably others) will have made the changes for you, or will make them if you so request. Others, like Webervations, will provide a text field in a setup form where you can paste in your code. However it is done, the resulting code on the booking engines should look like this:

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-X']);
_gaq.push(['_setDomainName', 'none']);
_gaq.push(['_setAllowLinker', true]);

Actually, the key sections are setAccount, which must be set to your domain’s GA ID, and setAllowLinker, when set to “true” will allow you to track clicks back to your site. This code will allow the booking engine to use your tracking cookie for your transactions, but not for transactions by another lodging property. If your booking engine page has a link back to your site, the link should include the linker code:

<a href="www.YOURWEBSITE.com"
onclick="_gaq.push(['_link', 'www.YOURWEBSITE.com']); return false;">Return to Our Site</a>

Now that the website and booking engine tracking code is set up properly, we need to set up our goals.

Setting Up Your Completed Booking as a Goal

In your GA account (we’re using the “new” GA here, Google Analytics 5), click the little “gear” icon in the upper right, then click on the Goals tab. Next,

  • Click on “Goal+” to add a new Goal.
  • Give the goal a descriptive name, such as “Bookings”
  • select URL Destination as the type.
  • In the Goal URL box, enter the URL for the page you want to be the ultimate goal. For your booking engine, this should be the final page the visitor sees when the booking is complete. It may be a “Thank You” page, a Confirmation page, or something of that order. Do not include the domain, just the path to the final page. For example, we use the RezOvationGT Booking Engine, so our Goal URL is “/Reservations/ResConfirmation.aspx”. To find your Goal URL, try creating a test booking, and write down the URL’s of every page in the process.
  • Optionally put in a Goal Value (this is not the same as ecommerce tracking, but lets you assign a value to the goal – so if you feel a booking is worth $200, then entering that here will give you an idea of the value of the booking goal, and allows you to approximate the value of a referral source, for example.
  • The use of a Goal Funnel is optional, but we recommend using it. To do so, you need the URL’s you captured earlier, while making a test booking. Enter each one, one per line, as Steps in the Funnel. Do not make them Required, unless they actually are mandatory.
  • Save your Goal, and wait for results (usually 24 hours)

Once you have data from your goals, you’ll be able to see the referral sources that have sent them, and other data that may be helpful to you.

×