Welcome to SEO Boy, the authority on search engine optimization -- how to articles, industry news, insider tips, and more! If you like what you see, you can receive free and daily updates via email or RSS.
Print This Post Print This Post

Tracking Visitors Between 2 Websites in Google Analytics

April 29th, 2009 | | Advanced SEO Tips

Recently, we encountered a tracking issue with a client’s website.  What was the problem? Tracking visitors between multiple websites in Google Analytics. So, I thought I’d share the the problem and solution with you, just in case you ever have the same issue.

The website in question has a unique purchasing process that makes it difficult to complete the sales funnel in Google Analytics. This means we were having trouble attributing sales to specific keywords.

Why were we having this problem? Basically, this website has two sections. The first section we’ll call the “information” section. This is the homepage and we send users here tell them about our product offering, the benefits of our products, and why they should purchase from the site. Nothing too daunting  here.

The second section of the site is where the user can actually purchase our product. This is the “purchase” section of the site. Again, nothing too daunting here either.

However, when a user clicks on the “Buy Now” button they are taken to an entirely different site to make the purchase. Why? Because this client has a few different products that are promoted through numerous websites – but they track all of their sales from one central website. This makes tracking orders easier and fulfillment faster.

The reason why we couldn’t track sales back to keywords is because when a user clicked, “Buy Now,” on the homepage, Google Analytics was logging this action as an exit from the site. Which is actually correct, the user was leaving the site. But we needed to make the jump from the homepage to the “purchase” site so that we could track an order from beginning to end.

So, how can you track visitors between two domains? Good question! To track traffic between two domains you will need to complete a few steps to tag all of your links between the sites properly. Keep mind, this process is for the latest version of the Google Analytics code.

1. First, you’ll need to alter your Google Analytics code on each page for both websites. You will need to add these two lines of pageTracker code (in bold):

<script type=”text/javascript”>
var gaJsHost = ((“https:” == document.location.protocol) ? “https://ssl.” : “http://www.”);
document.write(unescape(“%3Cscript src=’” + gaJsHost + “google-analytics.com/ga.js’ type=’text/javascript’%3E%3C/script%3E”));
<script type=”text/javascript”>
var pageTracker = _gat._getTracker(“UA-12345-1″);

} catch(err) {}

2. Second, you’ll need to add the _link function to any links between the two websites. Please note that your Google Analytics tracking code and calls to _gat._getTracker (shown in Step 1) must be placed on the page above the call to _link. Basically, make sure that your GA code is the top of each page. If your current links look like this:

<a href=”https://www.purchasesite.com”>Purchase Now</a>

change them to:

<a href=”https://www.purchasesite.com” onclick=”pageTracker._link(this.href); return false;”>Purchase Now</a>

3. If you send information between domains using forms, you’ll need to use the _linkByPost function. Your Google Analytics tracking code and calls to _gat._getTracker (shown in Step 1) must be placed on the page above the call to _linkByPost. Again, just make sure that your GA code is at the top of each page. Here is an example:

<form action=”http://purchasesite.com/form.cgi” onSubmit=”javascript:pageTracker._linkByPost(this)”>

This will work even for forms where the method=”GET”

4. Also, according the GA help section: by default, the data in your reports will only include the Request URI and not the domain name. If you’d like to see the domain names in your reports, you can create an Advanced filter for your profile with the following settings:

Filter Type : Custom filter > Advanced
Field A : Hostname Extract A : (.*)
Field B : Request URI
Extract B : (.*)
Output To : Request URI
Constructor : $A1$B1

Your reports will be modified immediately after implementing this filter. The folks at Google Analytics also recommend implementing this filter in a new profile based on your existing tracking code. Filters and goals may also need to be modified to accommodate the new linking structure.

If you follow these instructions, you should be able to track visitors between two websites. This way you can track how a visitor found your site, clicked-through to your second site, and took the desire action!

Facebook   IN   Stumble Upon   Twitter   Sphinndo some of that social network stuff.
  • http://www.getreadyrentals.com Gaizka Pujana

    Hola Joe,

    First let me apologize for my English.

    My name is Gaizka Pujana and I am a Spanish guy from Barcelona and i have a few websites in which I sell accommodation in holiday apartments in the main European cities. I saw your post and i am going through this same problem.

    I would like to know if you could give me a hand with this matter.

    Thanks for your time.

  • http://www.digitalbuzz.com.au Dan

    Thanks great article. Very helpful and relevant for larger companies with multiple websites and campaigns.

  • Michael Mason

    Thanks Joe.

    I’ve implemented this and hope that tomorrow, or the day after it’s effected.

    Much easier to follow than the GA so called help…