Universal Analytics Tracking Script for IRM

This document describes how to set up Google’s Universal Analytics tracking script for IRM.Net such that the source of reservation revenue can be tracked in both multiple sub-domain and cross-domain scenarios. Universal Analytics has made setting up tracking across subdomains and separate domains easier than it has been in the past. If any customer is still using Classic Google Analytics and having trouble tracking the source of reservation revenue, the first step should be to update their google analytics account and tracking scripts on both the marketing and IRM sites to Universal Analytics. 

Most of our customers fall into this category. For example, www.resortdata.com and irm.resortdata.com are subdomains of the resortdata.com domain. If only the first part of the urls to the marketing web server and the irm web server are different, then follow the multiple sub-domains setup.

The customer can retrieve their tracking script from the google analytics UI / Admin section under ‘Tracking Info/ Tracking Code’. It will should look like this (with the x’s in the ‘create’ line replaced with the customers google analytics account number):

                (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
                ga('create', 'UA-xxxxxxxx-x', 'auto'); ga('send', 'pageview');

For IRM.Net add this script to both the trackpage.js and tracktransaction.htm files.  For IRM Mobile add this script to both the trackpage.js and tracktransaction.js files.

It is important that the script on the marketing site server and the script on the IRM server are the same.

If the domain of the marketing site is completely different than the domain of the irm web site, then this is a cross domain tracking scenario. For example, www.lacuna-creative.com and irm.resortdata.com are two separate domains and need cross domain tracking script. Our current IRM CCS and HCS demos and some of our customers fall into this category. 

To set up cross domain tracking, the script on the marketing site side and the IRM side must work together to tell each other about the two domains. Using our IRM demo scenario as an example, the marketing site is at www.lacuna-creative.com and IRM.Net is at irm.resortdata.com. So the script on the marketing side has to allow linking to the domain resortdata.com and the script on the IRM side has to allow linking to the domain lacuna-creative.com as follows: 

Marketing site script:

                (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
                ga('create', 'UA-xxxxxxxx-x', 'auto', { 'allowLinker': true}); ga('require',
                'linker'); ga('linker:autoLink', ['resortdata.com']); ga('send', 'pageview');

IRM site script:

                (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
                ga('create', 'UA-xxxxxxxx-x', 'auto', { 'allowLinker': true}); ga('require','linker');
                ga('linker:autoLink', ['lacuna-creative.com']); ga('send', 'pageview');

For IRM.net add this script to both the trackpage.js and tracktransaction.htm files, replacing the x’s with the customer’s google analytics account number and ‘lacuna-creative.com’ with the customer’s marketing site domain name. Likewise for the marketing site script, the x’s should be replaced with the customer’s google analytics account number and ‘resortdata.com’ with the customer’s irm server domain name. 

This is the support article from google that was followed to set this up: https://support.google.com/analytics/answer/1034342?hl=en. In our scenario, there are only two domains, so only the references to example-1.com and example-2.com from the article are applicable. We do not have a counterpart to example-3.com.

Additional Coding May be Necessary

With particular methods of linking to the IRM from the marketing site, additional coding may be necessary. Specifically:

  • The marking site has Javascript within the href of the link to load the link, for example: <a id="submitbutton" href="javascript:doSomething();">Submit<a>
  • The marking site has an element with an "onclick" attribute, for example: <a id="submitbutton" href="#" onclick="doSomething()">Submit<a>
  • The marketing site uses a form submit to link to the IRM

In either of first two situations, the doSomething() function will probably have a return false or preventDefault() to keep the anchor from working normally. The function will do something and then redirect the page to the desired URL. You’ll need to modify your doSomething() function to use a decorated URL. See the “ Decorate Utility Method” on the Google Developers pages.

In the third scenario (form submit), additional parameters must be added to the 'linker:autolink' line of script on both the marketing site and IRM as illustrated below. (resortdata.com and lacuna-creative.com to be replaced with the customer's IRM and marketing site domains.)

Marketing site:
              ga('linker:autoLink', ['resortdata.com'], false, true);
IRM site:
              ga('linker:autoLink', ['lacuna-creative.com'], false, true);

The ‘false’ parameter in the ga(‘linker:autoLink’,...) line means that the _ga parameter will be sent to IRM.net on the query string portion of the URL, which is what we want. (A true value here would indicate sending it on the anchor portion, #, of the URL.) The ‘true’ parameter means that the _ga parameter will be added to a form submit. This is applicable if the IRM is invoked from the marketing site via a form submit action. 

In order to test tracking of traffic source, it is very important to clear the browser’s cookies before each test. Universal Analytics uses cookies to pass information around and the cookies do not expire for quite a while, so the only way to ensure that you are testing the latest changes to the script is to clear all the cookies first.

Using a not so popular search engine is a good way to test if the source is being correctly tracked. It’s helpful to be able to look at the data in google analytics while testing. Either ask the customer to temporarily add you as a reader to their google analytics account or webex to them with google analytics running. 

Test steps:

  1. Clear browser cookies
  2. Search for the customers marketing site using duckduckgo.com or bing
  3. Click on the link from the marketing site from the search results
  4. Using google analytics real time data display, you should be able to see a traffic source of duckduckgo.com or bing
  5. From the marketing site, click on their link to the irm
  6. If the traffic source now shows a referral of the marketing site, then something is not right. If it still shows duckduckgo, then proceed with making a reservation. With the real time data, you cannot tell exactly what the source was for each page. You have to analyze what you see and draw a likely conclusion. It’s just a guideline at this point, but if you see the source change to the marketing site - no need to book yet, because something is wrong. 
  7. The real test is to book a reservation, which unfortunately, the results aren’t available until the next day. Make a note of your reservation number and cancel the res. (There is no need to wait until the results are available in google in order to cancel.) 
  8. Next day, look at the reservation (called a transaction in google) under the Reporting section, Conversions/ Ecommerce/ Transactions and choose ‘Acquisition/ Source’ from the Secondary Dimension dropdown. If all is well, you will see duckduckgo as the source for your reservation.