One of Google Analytics’ great features is that it can track visitors across multiple domains. This is especially handy for all those folks using a third party shopping cart. Getting GA configured correctly to work with a third party domain is not overly complicated but there can be some issues.
Here’s my list of the top mistakes made when working with a third party domain:
1. Missing GA tracking code
This is a simple step that many people forget. Make sure that you add the GA tracking code to all the pages on both domains. If the code is missing then the visitor will not be tracked. If the third party site does not allow you to add JavaScript to the pages then you may be out of luck.
Remember, the JavaScript code snippet needs to be modified slightly to look like this:
Don’t forget to replace “UA-XXXX-X” with your GA account number.
2. Missing __utmLinker() or __utmLinkPost()
The technology that GA uses to track visitors between multiple domains depends on two JavaScript functions: __utmLinker()
and __utmLinkPost()
. Both functions are included in the urchin.js tracking code. These functions transfer the GA tracking cookies from one domain to another via the URL. This is vital to identifying unique visitors and connecting which marketing activities lead to conversions.
Why do we need to transfer cookies between domains? Well, that’s a bit complicated and pretty technical. Think of it this way. Each visitor has their own set of cookies. For security reasons, we need a mechanism to transfer the cookies from one domain to the other. __utmLinker()
and __utmLinkPost()
are the mechanisms we use to transfer the cookies from one domain to another.
If you move visitors from one domain to another using regular links then you need to modify those links with the __utmLinker()
function. Here’s an example:
If you move visitors between domains using a form, then you need to modify said form using __utmLinkPost()
, like this:
I’m wondering what the effect of using the JS href would be on SEO? Any idea how a Google bot would make the jump through that type of link? Thanks very much for these tutorials, great stuff. My forehead and keyboard both thank you.
Hey Josh,
Great question. I’m not 100% sure how the googlebot would respond. I do know that the noscript tag is there so people with JavaScript disabled can still surf the site. As most spiders are not JavaScript enabled I’m guessing that they would take advantage of this as well.
Justin
Hi Justin, thank you you for this great post. My concern is pretty similar to the one above. I’m not a javascript expert, but I was wondering if we could trigger the utmLinker function in a more SEO friendly way, like
href=”http://www.example.com/” onclick=”javascript:__utmLinker(this)”
or something (altought I know this doesn’t work…)?
Thanks you
Hi Julien,
I have my doubts that your example will work. But to be sure I need to run a test. The reason is that many web browsers may still pass the user on to the URL in the HREF attribute even though there is a function reference in the onClick event. If the browser uses the value in the HREF then the cookies will be left behind.
Is there an HTML expert out there? If so, maybe they can chime in before I run my test.
Justin
Hi Justin, Thanks for the great posts. Here is my question. I have an application that is served up by many domains (www.mydomain.com, http://www.anotherdomain.com, etc.). I track all visits using my account (www.mydomain.com) and my customers track their individual visits using their own account (www.anotherdomain.com). We programmatically insert the java script for them. My question is will my tracking work if my account is setup using http://www.mydomain.com even when pages are being served up using http://www.anotherdomain.com?
Hi Joe,
Without knowing al the details it’s tough to say. But, from a high level, I think you’re ok.
GA is completely client side. So, if the page renders with the correct JS snippet then the page will be tracked correctly. As long as the page has the correct GA tracking number.
Justin
Hi,
I’m wondering how to pass the GA cookies via Header-Redirection. I’m pretty sure I cannot use the given utmLinker function as it should be, so I’d really appreciate some help.
My customer’s script checks a certain parameter given via URL and redirects to a different ssl url if necessary. So I cannot combine the HTML-Link with the utmLinker function.
Andreas
Hi Andreas,
The problem with passing he tracking cookies using a method other than __utmLinker() or __utmLinkPost() is creating the checksum. When __utmLinker() and __utmLinkPost() execute they create a check sum that is attached to the destination URL. If the checksum in the UL does not match the checksum that is computed when the visitor arrives on the destination page, then GA will set new cookies.
Unfortunately using a header redirect will not calculate the checksum value.
Hope that helps…
Justin
This is nuts.
Google’s analytics fall WAY SHORT in this department.
For them to expect users to change all links in order for the multi-domain tracking to work is INSANE.
Hi Randy,
Multi domain tracking is a challenge. The problem is that Google Analytics uses first party cookies. Therefore, there must be some mechanism to pass cookie values from one domain to another so that the cookies remain first party cookies. I don’t know any other way to pass the data.
One solution is to create a DOM script that automatically calls the utmLinker() function when the links are clicked on.
There may be other mechanisms for passing cookies between domains, but I don’t know any others.
Thanks for the feedback!
Justin
Hi Justin,
Re tracking across multiple domains:
After the scripts have been implemented and the intersite links revised, when clicking on the link from seconddomain.com to firstdomain.com, have you run into the problem where there’s an “error on page” in IE but it works without any problem in Firefox and Safari?
We’ve checked our JavaScript syntax between sites and can’t see any IE-related eccentricities.
Thanks,
June
Hi June,
I have not run into that problem before. The only thing that comes to mind is that there may be an utmLinker() call before the urchin.js file is loaded into the browser.
Is it working when a visitor clicks from firstdomain.com to seconddomain.com?
Justin
Hi Justin,
utmLinker() is after urchin.js. It’s working/tracking in Firefox and Safari.
Will dig further and share what we find.
Thanks,
June
Hi first of great post…
my question is this however.
if i past my GA code like so
_uacct = “UA-XXXXXX-X”;
urchinTracker();
will i still be able to track visits to a 3 party site ?
Hi ronaleee,
Adding the tracking code to the pages on both sites is just the first step in tracking across multiple domains.
You also need to modify the links or forms that direct a visitor from one domain to another. This post should provide all the information that you need to get things set up correctly. But, if you need more information check the Google Analytics support section here:
Tracking 3rd party domains
Hope that helps,
Justin
Hi Justin,
Have you been able to execute the link level javascript between multiple domains successfully where the “sending” domain content is part of a wordpress blog?
Thanks,
June
Hi,
Trying to come up with a way to visitors between sites with separate GA profiles so they do not just show up as a referral from the other site. Can you use the utmlinker or utmpost to pass visitors tracking data from 1 site to the other and maintain their original entry (orgainc,ppc,etc.) instead of just a referral from the other site.
Thanks,
Dwayne
I’m using code behind the scenes to store the values of all the variables (utma, utmb, utmc, utmd, utmv, utmz, and utmk) as session variables. I use the uhash function to get utmk. I’m pretty sure I got that hash value correct.
Then when the first domain redirects to the second domain, it adds “?__utma=xxx&__utmb=xxx&utmc=xxx&__utmz=xxx&__utmk=xxxxxxxx”. But new cookie values still seem to be getting set.
It would be so much easier if GA just allowed us to “preset” a,b,c,d,v,z in the page.
Hi Brian,
I’ve been trying for a long time to manually calculate utmk and pass it to a third party site. It has never worked.
One thing I noticed is that you listed a utmd cookie. To the best of my knowledge there is no utmd. :) That may be your problem. Also make sure you’re using the correct value for utmx even if you’re not using optimizer.
I think what would be very useful would be a function to create a formatted URL that has all the cookies, their values and any checksums.
Justin
Hi Dwayne,
Yes, utmLinker() and utmLinkPost() are used to pass the tracking cookies from one site to another. By passing the tracking cookies from one domain to another the original source of the visitor’s session will be retained.
Justin
Hi Justin,
Thanks for the help on tracking accross multiple domains. I just want to verify 1 more item when tracking accross the 2 domains (using separate profiles) with the utmlink or utmpost do I still need to modify the original code on both sites to add the _udn=”none”;
_ulink=1; lines of code?
Thanks again,
Dwayne
Hi Dwayne,
Yup, you’re correct.
Justin
ok forgive my ignores but after all of the above is done.
how can i see the goal conversion on my analytics account? do i have to modify it as well?
please help me nothing i have done works..
p.s great post easy to read and informative
Ronaleee,
To track conversions you need to set up Goals. Check this post for more information about how GA goals work and how you can set them up.
http://www.epikone.com/blog/2007/07/07/google-analytics-goals/
Good luck,
Justin
Hi Justin,
Say there are 2 domains A and B, and when a visitor clicks the order link on A, he is transferred to page B1 (order page) on domain B to place his order.
I have my GA code and utmLinker on domain A, however I can only place my GA code on page B2 (the thank you page) on B.
So a visitor would go from A (with GA code + utmlinker) to page B1 (no GA code) to page B2 (with GA code).
Would the tracking still work in this case? Or does the GA code have to be on all pages in domain B?
Thanks very much for your time!
Ethan
Hi Justin,
How would you suggest transfering cookies between 2 domains using frames. We want to track a page with a framed formulier (external) and back to the original site.
GA codes have been placed on both pages, but we seem to be missing the cookie details ie how to transfer as we are not dealing with a straight link or form here.
Thanks.
Nathaniel Stott
Hello,
I’d like to keep a log of user events on my website. I want to use the ID that urchin chooses for the user since it’s probably the most accurate way of identifying the same user between events.
It seems like __utmb records this identifier but I can’t find a definition for the purposes of the __utmX cookies anywhere.
Can you give me any advice?
thanks, Oliver
Hey Ethan,
Unfortunately you’re out of luck. While you will be able to track referrals, you will not be able to connect those referrals to the originating camapign information. The reason is that when the visitor clicks from B1 to B2 GA will create a set of tracking cookies for the B domain. Those cookies will not contain the original campaign info from site A because utmLinker was not used to pass the info from A to B2.
Sorry about that.
Thanks for reading and thanks for the question.
Justin
Hi Nathaniel,
Trasfering the cookies between frames is really hard and there is no solution yet. The problem is that utmLinker and utmLinkPost attach the cookie values to the destination URL and then do a redirect. Obviously, with a frame, the SRC value is already set when the page is rendering in the browser.
I’ve been trying to work on a solution with a friend at Google but I have not getting it to work. If i do figure somethin out I’ll post it here.
Justin
Hi Oliver,
The best place to find an explanation of the UTM tracking cookies is in GA Short Cut. While it is GA focused, the tracking cookies are the same for Urchin.
Thanks for the question,
Justin
If the 3rd party page already has their own urchintracker script (with their own acct #), and we also put our own urchintracker script in the same page (probably above theirs, with our own acct #), would analytics still work for both of us? Would the transferred cookie info be picked up by our own script?
Jenny,
It is possible to track traffic in two different GA accounts, however the data can become mangled. The problem is that both sets of code share the same tracking code.
To track traffic in two accounts make sure to ‘reset’ the GA tracking code by adding the following line between the two sets of tracking code:
_uff=1;
Hope that helps,
Justin
Hi,
I want to post the link of my homepage on my orkut profile and want to track web-traffic from my orkut profile to my homepage. I already have an account for my homepage in Google analytics. Is there a way to track? pls. guide
thanks,
gaffe
Hi Gaffe,
You should be able to see Orkut as a referrer to your website already. If you need more specific information then I would tag the link on your Orkut homepage as you would a marketing campaign.
You can learn more about link tagging in this series of posts.
Thanks for reading,
Justin
silly question… does the GA uacct code have to be the same for domain1.com and domain2.com?
Hi JCC,
No such thing as a silly question. The answer is yes, the account numbers need to be the same on both sites.
Justin
I’ve been playing around with Google Analytics and getting utmlinker() values to survive a HTTP redirect on the receiving page. It was causing me problems at first, but found some help on the GA newsgroup which may be of use to others:
http://groups.google.com/group/analytics-help-tracking/browse_thread/thread/f913cf551aafab89/
Dave
Hi David,
Thanks for posting that link. Understanding the utmk checksum is really important if you’re trying to get around a redirect without using utmLInker. We’ve been using a couple of functions to compute the hash internally and have had some success. Hopefully that post solved your problem.
Thanks again,
Justin
Hi,
I faced a problem that no one on the net seems to have as I looked through thousands of posts.
I changed GA code (added two lines)
I added UTM to the link as you suggest in your post (and as Google suggests), but…
When I upload the site the link is unclickable. What I mean is you can see “buy now” words and you can see that it is a link, but when you click on it nothing happens (but you can open it in a new tab/window through the right click).
Any suggestions? Thanks in advance!
Hi Aleksa,
Make sure that the GATC, the main tracking code, is at the top of your HTML and not at the bottom. My guess is that the utmLInker or utmLinkPost functions are missing because the urchin.js script has not loaded into the browser when the visitor clicks on the link.
You may also want to check for any JS errors on the page.
Good luck and thanks for reading!
Justin
I am trying to wrap the utmLinker and utmLinkPost functions around existing forms which have their own onSubmit functions. There’s a 2nd parameter to utmLinker and utmLinkPost called ‘h’ that is undocumented but seems to be the return value of an existing onSubmit function, before adding your own. I can’t imagine what else it might be. Here is an example:
In this case, testfcn(this) would be the function I originally wanted to call before implementing utmLinkPost(). This implementation causes the return value of testfcn() to be passed in to utmLinkPost as true/false (as the ‘h’ param, I’m guessing). I just don’t understand the logic, then, of how it’s being checked against ‘ih’ which indicates the occurrence of a ‘#’ fragment in the action link.
Any thoughts? Is my assumption correct, and how is ‘h’ being used in conjunction with ‘ih’? Thanks,
Selene
Selene,
The problem with utmLinkPost() is that it performs a redirect after manipulating the form action. I would try calling the utmLinker() after your function. Obviously the interplay of the two functions really depends on the logic in your function. I’m pretty sure you’ll need to tweak your function to make this all work.
Hope that helps,
Justin
I tried this, but it seems that onSubmit only takes one function (I have read this on other forums as well). If I separate the functions and call them in sequence, only the first one (my function) is called but the 2nd one is not.
Also, in your response, did you mean to call utmLinkPost() after my function, or utmLinker()? I am working with a form, so I thought that the former (sorry for the inadvertent pun) was appropriate, and the latter was only for links.
S.
Hi Justin,
With the recent change from urchin.ja to ga.js, I have a few questions:
* Honestly, I don’t remember why I’m doing this, but I seem to be using your Javascript wrapper on the Buy links from my site to my cart on another site. It worked fine in urchin.js. But now that I read the GA docs, they just recommend using this link format below. Why do you wrap the whole thing in a script and have a separate noscript version?
Purchase Now
* I need to switch, I think, to ga.js, because my cart host is using that now on the receipt page to track transactions. Is there any reason to to modify your Javascript wrapper so it does pageTracker._link instead of __utmLinker? Or would it make more sense to just use what GA suggests, namely:
Purchase Now
Thanks!
cheers… -Adam
Hi Justin,
With the recent change from urchin.ja to ga.js, I have a few questions:
* Honestly, I don’t remember why I’m doing this, but I seem to be using your Javascript wrapper on the Buy links from my site to my cart on another site. It worked fine in urchin.js. But now that I read the GA docs, they just recommend using this link format below. Why do you wrap the whole thing in a script and have a separate noscript version?
a href=” https://www.securecart.com/?store=parameters” onclick=”__utmLinker(this.href); return false;”>Purchase Now /a
* I need to switch, I think, to ga.js, because my cart host is using that now on the receipt page to track transactions. Is there any reason to to modify your Javascript wrapper so it does pageTracker._link instead of __utmLinker? Or would it make more sense to just use what GA suggests, namely:
a href=” https://www.securecart.com/?store=parameters” onclick=”pageTracker._link(this.href); return false;”>Purchase Now /a
Thanks!
cheers… -Adam (reposting so my links appear as text)
Hi Adam,
If you’re using a third party shopping cart make sure that you’re using the same tracking code that your cart provider is using. If they’re using urchin.js make sure you are using urchin.js.
The reason is that the cookies for urchin.js are slightly different than the cookies on ga.js, this can cause problems with the cross domain tracking.
Re: your question about __utmLinker() and pageTracker._link(), each is specific to a different version of the tracking code. If you’re using urchin.js make sure you use the __utmLinker() function. If you’re using ga.js make sure you’re using pageTracker._link().
Justin
I am trying to delete this site from my analytics account but don’t know how. I deleted it but it is still there.
The tracking code is “UA5176365-1”
Can you help me with this or direct me to someone who can help me?
Hi Jeanne,
I’m nt exactly sure what you’re asking. You should be able to delete any profile from your account except for the original profile. You can’t have a GA account without any profiles.
If you want to stop tracking a site just remove the code from the site.
Hope that helps and thanks for the question,
Justin
Hi Justin – I heard that the tracking between sites is no longer allowed (I think it had to do with privacy concerns). If this is incorrect is adding the new GA.js code to the third party site all that is required, or is there more to it?
Let me know, thanks.
Hi JJ-
It is possible to use GA to track visitors from one domain to another. To implement cross domain tracking you need to add a modified version of the tracking code to each site AND you need to modify the forms and links that point from one domain to the other.
Check the GA help section for amore info about the GA.JS implementation.
Thanks for the question,
Justin
I am really banging my head against a brick wall on this one.. perhaps someone here can help.
I have a form posting to a 3rd party site and have followed the configuration instructions to track across domains… the URL that the form posts to on the 3rd party domain contains all the __utma, __utmb…__utmz variables, but the __utma and __utmz cookies that get set are different — the __utmz cookie that gets set on the third party site indicates that I am being referred by my main website.
Any ideas where I should start looking to sort this?
Hi bB,
If you can see the cookies in the URL when you land on the new site then things should work. I would check to make sure that both sites are using the same version of the tracking code. You could run into trouble if one site is using urchin.js and ga.js.
Hope that helps,
Justin
Hi
I was just wondering if anybody knows anything about posting data on google analytics without using javascripts. Any advice would be greatly appreciated.
Thanks a lot for your time.
Padma.
Hi Padma,
Right now the only way to get data into GA is via the JS code. So you need to execute JS to send data to Google.
If you figure out away to get JS to execute at the sever level let me know!
Justin
I’m looking at moving my blogspot blog to my own domain.
e.g.: myblog.blogspot.com -> blog.myblog.com
Blogspot automatically redirects all requests for the old domain to the new one, so all traffic will come from the one domain. I’d like to keep my old stats after the move.
Do I still need to make changes to the GA tracking code (domain name to “none” and turning on linker)? Or will the old code still work even though it is being called from a different domain? (I understand the returning visitors etc. will be out because the cookie will change.)
Regards,
David
David,
No need to change anything. I believe that Blogger uses a 301 redirect, which is what you want.
Thanks for the question,
Justin