Reputation: 153
does anyone know whether Google Analytics (360?) provide options to use custom domain so the analytics data will be submitted to that domain?
Upvotes: 1
Views: 1373
Reputation: 32760
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).
Upvotes: 3
Reputation: 69
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.
Upvotes: 1