I am trying to set up my website to have cross domain tracking with the online store Gumroad.com, inside my Google Analytics. So that I can follow the user events from one site onto the next.
Gumroad has instructions at this link, but they are in the format of a script to be pasted into the site.
I use Tag Manager and am wanting to input these parameters into my Google Analytics Settings variable (which is how Google recommends doing Cross domain tracking with Tag Manager)
I'll attach the script that they provided, as well as my Google Analytics Settings variable in Tag Manager. If anyone knows how to set up the rest of the parameters that would be greatly appreciated!
Script:
<script>
// mystorefront.com is your site's domain.
ga('create', 'UA-XXXXX-Y', 'mystorefront.com;, {'name': 'sampleTracker', 'allowLinker': true, ';cookieDomain': 'mystorefront.com'});
ga('sampleTracker.require', 'linker');
ga('sampleTracker.linker:autoLink', ['mystorefront.com']);
ga('sampleTracker.send', 'pageview');
</script>
My Tag Manager (Google Analytics Settings variable) setup so far:
[]
Set domains in list without protocol.
It also does not make sense that you use cookieDomain as Field to set when it is already defined in the field below the tracking ID.
does anyone know whether Google Analytics (360?) provide options to use custom domain so the analytics data will be submitted to that domain?
If I understand the question correctly you want to modify the GA tracking code so that it sends the raw data not to the GA server, but to your own server.
You can do this via a custom sendHitTask. Tasks in GA are parts of the tracking code that are responsible for assembling and collecting data before it is send to the tracking server. Tags can be overwritten to implement custom behaviour.
If you want to add to a task you would usually use the customTask which was specifically introduced to add custom behaviour. But since you apparently want to replace the original function completely you might just as well override the sendHitTask, i.e. the part of the code that sends the hit.
This is pretty much the example from the documentation that would send the hit to an url on the server your website runs on:
ga('create', 'UA-XXXXX-Y', 'auto');
ga(function(tracker) {
// Modifies sendHitTask to send a copy of the request to a local server
tracker.set('sendHitTask', function(model) {
var xhr = new XMLHttpRequest();
xhr.open('POST', '/localhits', true);
xhr.send(model.get('hitPayload'));
});
});
ga('send', 'pageview');
The bit where is says model.get('hitPayload') retrieves the url query string with the tracking data. You'd then need to implement your custom way to send the data to your server.
Obviously this is raw data. You would need to aggregate it yourself on your target server.
There is no self-host Google Analytics (for classic Analytics there used to be a stand-alone version that you could install on your server, but that was discontinued after the switch to Universal Analytics).
If you are talking about multiple domain and/or sub-domain, yes you can.
Or if you have multiple directories for same domain that is also possible.
We have a webapplication hosted on our servers.
Some customers use our predefined (sub)domains and some other customers use their own domain (paid users).
As I want to track total usage of all established webapps I'd like to use the same tracking code on all domains?
The customers can add their own tracking code too (I've already figured out how to do this).
So is it possible to do it like this?
sub1.domain.com -> UA-XXXXXXX-1
sub2.domain.com -> UA-XXXXXXX-1
customer3.com -> UA-XXXXXXX-1
customer4.com -> UA-XXXXXXX-1
Here are the best tutorial for it
http://www.ericmobley.net/guide-to-tracking-multiple-subdomains-in-google-analytics/
https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingSite#multipleDomains
The trick is the cookies domain property:
ga('create', 'UA-XXXX-Y', {'cookieDomain': 'example.com'});
ga('create', 'UA-XXXX-Y', auto);
most of the time you setup as auto. Check the doc for more info about the cookieDomain.
To Tracking Across a Domain and Its Subdomains
As mentioned above, a default setup of Google Analytics is designed to
track content and visitor data for a single domain, such as
www.example.com. This means that even if you manage both a domain and
a sub-domain, you must make modifications to the tracking code in
order to share visitor data across both domains.
Display Subdomains In Your Analytics Data using custom filters and Set Up A View For Each Subdomain (Optional).
I manage multiple e-commerce sites that all share the same checkout process but have individual google-analytics accounts. Under the old google analytics for cross-domain tracking we used:
['_setDomainName', 'none']
When on the SSL checkout part of the process.
Under universal analytics I understand you can use linker plugin for cross-domain tracking but I don't see an equivalent to the 'none' configuration above. What is the correct way to achieve this?
I hope I understand your problem correctly. The best explanation is on the Google Documentation page but I'll try to make a summary.
The _setDomainName configuration, on ga.js, sets the domain name for the Google Analytics cookies:
_gaq.push(['_setDomainName', 'mywebsite.com']);
On analytics.js, the new way to do this is:
ga('create', 'UA-XXXXX-Y', {
cookieDomain: 'mywebsite.com'
});
And if you'd like to use the legacy cookies (from ga.js), you also should populate the legacyCookieDomain setting:
ga('create', 'UA-XXXXX-Y', {
cookieDomain: 'mywebsite.com',
legacyCookieDomain: 'mywebsite.com'
});
There are two ways to have an equivalent to the 'none' configuration. The first one is:
ga('create', 'UA-XXXX-Y', {
'cookieDomain': 'none'
});
But Google suggests to use this solution to set cookies on localhost. The second solution is sending data directly to Google Analytics without the use of cookies.
ga('create', 'UA-XXXX-Y', {
'storage': 'none',
'clientId': '35009a79-1a05-49d7-b876-2b884d0f825b'
});
Here you'll have to supply your own clientId parameter.
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