I have tried using analytics.js (Universal Analytics) through both frontend (js) and backend(Measurement protocol).
When using through frontend (js way):
I check that there is a cookie named _ga whose value is GA1.2.1360127879.1438853622 . And it is sending data to GA with cid=1360127879.1438853622 through request 'http://www.google-analytics.com/collect?...' . I know that 1360127879 is the unique id and 1438853622 is the timestamp.
When using through backend (Measurement Protocol):
I have few questions here:
1. How can i get the client id from browser?
One way is to read the _ga cookie from backend and parse the client id from it.But i read that it is not recommended.Because google can change the format anytime.Somewhere i read that use:
ga(function(tracker) {
var clientId = tracker.get('clientId');
});
But i am not getting how to get the client id in backend using this? I want to use the same client id which frontend is using.
2. What is actually the client id? Is it the unique id alone or the combination of unique_id.timestamp. What should i send to GA from backend?