Track Google Analytics conversions from domain to subdomain - google-analytics

I'd like to track the conversion rate of my site using Google Analytics across multiple subdomains.
The scenario:
A: www.site.com <- where sessions begin.
B: app.site.com <- where sign up starts.
A conversion for www.site.com is a session moving to app.site.com.
Currently conversions on site.com look like drop offs.
I've already set up two views to separate A and B.
Side note: B is ignoring referrals from A.
I've set up conversion tracking on B.
My question is: how do I track the conversion of site.com sessions travelling to app.site.com using Google's Universal Analytics?

Are you using analytics.js? If so this happens automatically.
The main way people screw it up is by not setting cookieDomain to 'auto', which, if you use the default snippet, should already be the case:
ga('create', 'UA-XXXX-Y', 'auto');
Without seeing your implementation, it's impossible to know why yours isn't working, but just know this does work out of the box with no special configuration.

According to the developer site, Universal Analytics does not require further customisation to the _ga cookie. Use the default analytics.js code snippet to track between your domain and subdomain. Make sure to use the javascript code in both websites.
If you require that a visit to app.site.com is considered a conversion in site.com, then you need to attach an event to the link in site.com that points to the app.site.com and setup a goal for that event.
Have a read to this article, hope that helps.
Cheers

Related

How to set up cross-domain tracking in GA4?

How to set up cross-domain tracking in GA4 right?
I followed official instructions: [GA4] Set up cross-domain measurement
I've added all the domains I need to the Date Stream Details - More Tagging Settings - Configure your Domains.
Added 'Google Analytics: GA4 Configuration' tag on the website using Google Tag Manager.
But now, when switching between domains, a lengthy parameter
(smth like "?_gl=11lop9ld*_gaNDcxNTp2McYzKjE2LTcxMjQwKLv._ga_3JP1WO1NB3MTYxNzEyNDA4Ny8xLjEuKOPxNzEyNLI5Ny40Nw..")
is added to the page address and the page does not open, a 404 error appears.
What could be the problem?
As #Tony McCreath said, It might be a problem on the website's end on handling unexpected query parameters. I already faced this problem while working on a client website, and there was nothing that could be done on the Analytics side to fix the issue. You can test if that's the case by adding any random parameters at the end of the URL to see if the website still works.
The lengthy parameter that is added to the URL is the way Google uses to identify that a user is coming from another domain. It's basically an ID that will link the user from the previous domain to the current one.

Google Analytics - one real time monitoring for more domains

Is it possible to set up google analytics for more domains with one real time monitoring.
I have one main domain and 100 subdomains.
Example:
main.com
sub1.main.com
sub2.main.com
sub3.main.com
...
I want to track visitors in one google account with one real time monitoring. How can I do that?
Thanks
You do that by adding the same Google Analytics tracking code to multiple domains. The base domain from the Property/View settings are not relevant for data collection, so the same code will run on arbitrary domains.
(edited) Even less of a problem with subdomains. The default setting for the cookie domain is "auto", so the same cookie will be used for all subdomains. If you do not want this (e.g. if you want a user who switches between subdomains to be considered a new user) then you would need to set the cookie domain dynamically to the respective subdomain:
ga('create', 'UA-XXXXX-Y', {
'cookieDomain': document.location.hostname
});
However by default the reports displays page paths, so you might not be able to tell from which domain a request originated; to do that you need to add a filter to your view that adds the hostname to the page path. An older but still working tutorial is e.g. here.
Naturally everything that shows up in real time monitoring will later become part of the permanent reports.

Do webservers have to be publicly accessible for Google Universal Analytics to work?

I am using the "Bi-directional cross-domain tracking" script from Google to track visitors on a secondairy domain.
This is the script I am using:
ga('create', 'UA-xxxxxx-1', 'auto', { 'allowLinker': true });
ga('require', 'linker');
ga('linker:autoLink', ['main.com', 'secondary.com']);
ga('send', 'pageview', window.location.pathname);
The script can be found here:
Analyics.js Linker
I also made sure both domains were included in the "Referral exclusion list".
I have installed Google Tag Assistant (a Chrome extension), and it works like it's supposed to. I get a green icon, and also the message that 1 request is made. But I don't see any hits in Google Analytics.
I called with Google helpdesk, and only then I realised that 'secondary.com' is a server (used for testing) accessible only on our internal network.
Is that the reason why there are no results in Google Analytics?
Update
When we put our code in production we did get results in Google Analytics.
But that does not automatically mean that a server should be publicly accessible for the code to work, because maybe the problem was that the test server was on a sub-domain.
To make things clear we have:
companyname.nl (main.com in code)
mycompanyname.nl (secondary.com in code)
test.companyname.nl (the server that is not accessible from the outside)
According to the documentation:
Automatic cookie domain configuration sets the _ga cookie on the highest level domain it can.
So I Assumed test subdomain would work too.
I will unaccept the answer from #eike-pierstorff since it's unclear what's really going on.
To answer your question quite literally, no, webservers must not be publicly accessible for Google Universal Analytics to work. The Google Analytics web tracking code does not run on the webserver, in runs in the browser (or other client program). So if the client can access both the internal network and the public internet this should work (
This is more or less the end of the answer, I'll add a few more things in the hope it will help.
For the Google tracking code to work it must be able to set a cookie (or configured with 'storage': 'none' and have a client id set by your application), so you'd have to check if your internal url is actually a fully qualified domain name (so js cookies can be set; I'm not sure if secondary.com is just an example or if this is the actual format used in the internal domain name). But even then you should at least see traffic from the public url. The fact that you do not (plus you receive a green light from Tag Assistant) suggests that the problem is not at the collection end.
Did you by chance set up any filters that might affect the way data is collected ? In particular include filters are tricky (since they delete all data that doesn't match a pattern, so if the pattern is wrong they delete everything). If you haven't done it yet create a view without any filters to always have a backup of your data when a filter is misconfigured.
Since you mentioned these in the posts, neither the referral exclusion list nor the linker are likely to have anything to do with your problem; the first maintains the original channel attribution when people switch between domains, the second adds a parameter to links and form actions that allows the other domain to pick up the client id and thus continue the session. The worst that could happen is that cross domain tracking does not work, but sessions on both domains would still be (separately) tracked.

multiple domains, how to use the same GA property

I am trying to implement cross domain tracking for two of my domains. While reading the Google Docs on the matter, I got confused by the following paragraph toward the end of the article (bold text):
Both domains need to use the same GA property in order for cross-domain tracking to work correctly. If the sites use different properties, no session information will be shared and cross-domain tracking will not work.
Cross-domain tracking supports multiple trackers, but be aware that they will all share the same Client ID used by the linker.
The scenario I have is:
example.com --> the first domain used to promote my product
domain2.com --> the second domain which is used for secure checkout.
When creating a properly in Analytics, I need to enter the default url. How can I set this up so that I can then use the same property code for both domains?
Can't find any other related questions or articles on this, so I feel I am missing something simple.
It means that you have to use the same UA ID on both sites so that the GA property can collect the data on those 2 sites. You should use GTM to do cross domain tracking since it is much easier to set-up.
I recommend following the instructions here http://www.lunametrics.com/blog/2015/06/16/cross-domain-tracking-with-google-tag-manager/

Can you test google analytics on a localhost address?

I have to test out my new GA account on my local machine.
Will this work just by copying the standard snippet supplied by Google onto the page ?
I don't want to spend 24 hours waiting to see if it will or won't work.
This question remains valid today, however the technology has changed. The old Urchin tracker is deprecated and obsolete. The new asynchronous Google Analytics tracking code uses slightly different code to achieve the same results.
Google Analytics Classic - Asynchronous Syntax - ga.js
The current syntax for setting the tracking domain to none on google analytics looks like this:
_gaq.push(['_setDomainName', 'none']);
Google analytics will then fire off the _utm.gif tracker request on localhost. You can verify this by opening the developer tools in your favorite browser and watching the network requests during page load. If it is working you will see a request for _utm.gif in the network requests list.
Updated 2013 for Universal Analytics - analytics.js
Google released a new version of analytics called "Universal Analytics" (late 2012 or early 2013). As I write, this the program is still in BETA so the above code is still recommended for most users with existing installations of Google Analytics.
However, for new developments using the new analytics.js code, the Google Analytics, Advanced Configuration - Web Tracking Documentation shows that we can test Universal Analytics on localhost with this new code:
ga('create', 'UA-XXXX-Y', {
'cookieDomain': 'none'
});
Check out the linked documentation for more details on advanced configuration of Universal Analytics.
Update 2019
Both Global Site Tag - gtag.js and Universal Analytics - analytics.js will detect localhost automatically. You do not need to make any change to the configuration.
If gtag.js detects that you're running a server locally (e.g. localhost), it automatically sets the cookie_domain to 'none'.
- developers.google.com
Updated for 2014
This can now be achieved by simply setting the domain to none.
ga('create', 'UA-XXXX-Y', 'none');
See: https://developers.google.com/analytics/devguides/collection/analyticsjs/domains#localhost
I had the same problem, and all the solutions didn't work until I did two things:
Obvious code:
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXXX-X']);
_gaq.push(['_setDomainName', 'none']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview']);
AND
I added localhost another FQDN - domain name. I did this on Windows sistem by editing:
C:\Windows\System32\drivers\etc\hosts
file, and I put in the following:
127.0.0.1 my.domain.org
Then I went to address http://my.domain.org/WebApp that is serving page with included google analytics JS.
If you are on unix, edit /etc/hosts for same result.
It think that Google should put Intranet configuration in ther GA FAQ. They just say that you need FQDA. Yes, you do, but not for them to access you, you need it just to have Host attribute in HTTP request.
I think another reason for FQDN is COOKIES! Cookies are used to track data and if you don't have FQDN, cookie can not be set, and JS code stops and doesn't get the gif.
After spending about two hours trying to come up with a solution I realized that I had adblockers blocking the call to GA. Once I turned them off I was good to go.
Answer for 2019
The best practice is to setup two separate properties for your development/staging, and your production servers.
You do not want to pollute your Analytics data with test, and setting up filters is not pleasant if you are forced to do that.
That being said, Google Analytics now has real time tracking, and if you want to track Campaigns or Transactions, the lag is around 1 minute until the data is shown on the page, as long as you select the current day.
For example, you create Site and Site Test, and each one ha UA-XXXX-Y code.
In your application logic, where you serve the analytics JavaScript, check your environment and for production use your Site UA-XXXX-Y, and for staging/development use the Site Test one.
You can have this setup until you learn the ins and outs of GA, and then remove it, or keep it if you need to make constant changes (which you will test on development/staging first).
Source: personal experience, various articles.
Now the answer for your question is yes, it will just work by copying the standard snippet. According to documentation, now the standard snippet has automatic cookie domain configuration: ga('create', 'UA-XXXXX-Y', 'auto'); where cookie domain is automatically determined.
In addition, if analytics.js detects that you're running a server
locally (e.g. localhost) it automatically sets the cookieDomain to
'none'.
It will work if you use an IP or set domain to none.
Details here:
http://analyticsimpact.com/2011/01/20/google-analytics-on-intranets-and-development-servers-fqdn/
An easier tool to monitor the tracking tags is to use the Chrome extension (probably available, or the equivalent for other browsers) - Google Tag Assistant. This will show what tags are firing, what problems it has found, and even breaks out stuff like eCommerce values for easy reading. Also works with the Google Tag Manager, and can handle multiple sets of tags on the page.
I just want to add to what's been said so far, it may save a lot of headache, you don't need to wait 24 hour to see if it works, yes the total overview take 24 hour, but in Reporting tab, there is a link on left side to Real-Time result and it will show if anyone currently visiting your site, also I didn't have to set 'cookieDomain': 'none' for it to work on localhost, my setting is on 'auto' and it works just fine (I'm using MVC 5), on top of that I've added the script at the end of head tag as google stated in this page:
Paste your snippet (unaltered, in its entirety) into every web page you want to track. Paste it immediately before the closing </head> tag.
here is more info on how to check to see if analytics works properly.
Following on from Tuong Lu Kim's answer:
Assuming:
ga('create', 'UA-XXXXX-Y', 'auto');
...if analytics.js detects that you're running a server locally (e.g. localhost) it automatically sets the cookieDomain to 'none'....
Excerpt from:
Automatic cookie domain configuration sets the _ga cookie on the highest level domain it can. For example, if your website address is blog.example.co.uk, analytics.js will set the cookie domain to .example.co.uk. In addition, if analytics.js detects that you're running a server locally (e.g. localhost) it automatically sets the cookieDomain to 'none'.
The recommended JavaScript tracking snippet sets the string 'auto' for the cookieDomain field:
Source: https://developers.google.com/analytics/devguides/collection/analyticsjs/cookies-user-id#automatic_cookie_domain_configuration
I came across this problem recently, and I found it helpful to explore the new documentation by Google on debugging Analytics. It didn't actually care about sending tracking info to Google Analytics, I just wanted to ensure that the events were firing correctly, and the debugging tools gave me the info I needed. YMMV, I realize doesn't exactly answer the question.
For those using google tag manager to integrate with google analytics events you can do what the guys mentioned about to set the cookies flag to none from GTM it self
open GTM > variables > google analytics variables > and set the cookies tag to none

Resources