How Google Analytics Tracks Third-Party Domains
June 25, 2006 by Justin CutroniTime for another installment of how to set up Google Analytics the right way! Today we’re going to talk about how to configure GA if your website spans multiple domain names. This is often the case if you’re using a third party shopping card. Just a note, I’m not going to get into the actual installation steps in this post. I want this to be a conceptual. If you’re looking for step by step instructions you can contact me or find them on them here on the GA Support Site:
http://www.google.com/support/analytics/bin/answer.py?answer=26915&hl=en
Before we get into the nuts and bolts of the setup, it’s important to understand the fundamentals of how GA tracks visitors. GA uses first party cookies to identify your site visitors. We all know what cookies are, right? First party cookies are set with the same domain name that is in the location bar of the visitor’s browser. It is very important to understand that cookies can only be ’seen’, and changed, by the domain that sets them. In fact, it is almost impossible for a website to set a cookie for a different website. This is due to a default security setting that most browsers have. Website A can not set a cookie for website B.
Let’s take this knowledge and apply it to how GA works. When a user lands on a page in your site the urchin.js tracking code looks for the GA tracking cookies. If it finds the cookies then it updates them. If it does not find the cookies it sets them. Remember, if your website domain is www.shirts.com, then the urchin.js tracking code can only recognize cookies with the www.shirts.com domain and it can only set cookies for the www.shirts.com domain.
As the user continues their session the urchin.js interacts with the tracking cookies. Continuing with our example, the user on our site is just about to click on a link to different domain, the third party e-commerce platform we use. They will leave our domain and go to the e-commerce provider’s domain. We’ve been tracking this user with a specific set of cookies on our domain. When the visitor leaves our domain we want them to take their cookies with them. The cookies identify them as a unique visitor, if they don’t take their cookies to the next domain then we will loose the rest of their session information and that’s not good.
So how do we transfer the cookies to the shopping cart site? With Google Analytics we can pass the cookie values to the shopping cart domain via the query string. There are two conditions that need to be met for this technique to work:
- We need to add the urchin.js tracking code to the pages on the third party domain (I’ll explain this in a second).
- The third party domain must permit us to pass data via the query string.
If the third party domain does not allow the above then you can NOT use GA to track your visitors on the shopping cart pages. Sorry, there’s no way around it, both conditions must be met.
Here’s how we normally configure GA to work with a third party site. We wrap the link (or form) that directs the user to the third party site in a JavaScript function. This function literally picks up the cookie values from the visitor’s computer, appends them to the URL and then forwards the user to the third party domain. Once the user arrives on the destination page the urchin.js pulls the cookie values from the URL and sets a new set of cookies with the values extracted from the URL. That’s why we need to add the urchin.js to the pages on the third-party site. We need the code in the JavaScript file to pull the values for the cookies from the URL. It’s really important to understand this last step because it overcomes the two hurdles we discussed above.
First, we’re transferring the visitor’s cookie values from one domain to another. This means that the entire visitor session will be captured. All the identifying information for the visitor stays with the visitor as they traverse the different domains.
Second, the GA tracking cookies on the third-party site will be first party cookies so they are less likely to be rejected by the browser.
We all know that getting the complete picture of a visitor’s session is vital to better understanding of the referring information and site configuration. I hope this post gives people a better idea of how GA is tracking their traffic across third-party domains so they can configure it correctly.
Subscribe:










4 Responses to “How Google Analytics Tracks Third-Party Domains”
Great article! Do you know if Google Adwords conversion tracking and cross-channel tracking use the same method, especially if these cookies are also first party cookies? Regards, Ken Aston
By Ken Aston on Sep 25, 2006
Hi Ken,
I don’t know if AdWords can track users across multiple domains. Sorry!
Justin
By Justin on Sep 26, 2006
Is there anyway to pass the session data to the ecommerce site via POST instead of GET / Query String. My ecommerce solution is Volusion. They don’t allow non alphanumerics to be present in the query string variables. That screws things up.
By Casey on Nov 30, 2007
Hi Casey,
Unfortunately no. The data has to be passed via the query string.
Sorry about that…
Justin
By Justin Cutroni on Dec 3, 2007