UserID handling Client and Server events

652 views
Skip to first unread message

Neil Donnell

unread,
Nov 11, 2015, 5:38:24 PM11/11/15
to google-analytics-measurement-protocol

Hi All,

 

We have a Unity based game and are using the GA Unity plugin to send data from the client and we all also have a backend running on Parse.  We have enabled UserID and want both client and backend events related to a user to get captured properly but it seems that we have a situation where events fired from the server can override some of the client parameters.   For example we don't get the full user city location or the device becomes desktop when it should be tablet and mobile.

 

We have tried a few things but it seems like there is always a tradeoff.  What we really want is to be able to override all the server parameters with those from the client.

 

Has anyone solved this issue before?

 

Thank you for any pointers.

 

-Neil

Philip Walton

unread,
Nov 11, 2015, 5:43:31 PM11/11/15
to Neil Donnell, google-analytics-measurement-protocol

--
You received this message because you are subscribed to the Google Groups "google-analytics-measurement-protocol" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-analytics-measure...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-analytics-measurement-protocol/a5e29ead-a095-4315-8f7f-9512cf517328%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Neil Donnell

unread,
Nov 11, 2015, 5:59:41 PM11/11/15
to Philip Walton, google-analytics-measurement-protocol
Thank you for the reply but I suspect that would just allow me inject the User Agent.  What I think we require is something that allows us to piggy-back on the client properties or ‘ignore’ a bunch of parameters from the server but when we try that we get the ’not set’ value.

An example of what we see is:

Client fires up: mobile/country/city all correct in GA
Server fires an event in response to client action.  In realtime tracking of GA this user now becomes desktop/city ‘not set’

So we could do with some way of declaring the Clients properties to not get overwritten or something on the server that allows us to send ‘nothing’ for these events.

Any further advice appreciated.

Cheers,

Neil




You received this message because you are subscribed to a topic in the Google Groups "google-analytics-measurement-protocol" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-analytics-measurement-protocol/6b0O4m3yypc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-analytics-measure...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-analytics-measurement-protocol/CAChM%3Dvp_HDNQgntZTEk5GVL%3Dn6Bkw6CcHcq9AavDGgYH6mOg4w%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.

*********************************************************************
Confidentiality : This e-mail and any attachments are intended for the addressee only and may be confidential. If they come to you in error you must take no action based on them, nor must you copy or show them to anyone. Please advise the sender by replying to this e-mail immediately and then delete the original from your computer.
Opinion : Any opinions expressed in this e-mail are entirely those of the author and unless specifically stated to the contrary, are not necessarily those of the author’s employer.
Security Warning : Internet e-mail is not necessarily a secure communications medium and can be subject to data corruption. We advise that you consider this fact when e-mailing us.
Viruses : We have taken steps to ensure that this e-mail and any attachments are free from known viruses but in keeping with good computing practice, you should ensure that they are virus free.
Inspired Gaming (UK) Limited Registered in England No 3565640 Registered Office 3 The Maltings, Wetmore Road, Burton On Trent, Staffordshire DE14 1SE

Philip Walton

unread,
Nov 11, 2015, 6:04:22 PM11/11/15
to Neil Donnell, google-analytics-measurement-protocol
A combination of the UA override and the IP override should accomplish what you want.

Google Analytics gets its mobile/desktop data from the User Agent string in the request, and if the request is coming from a server without using the UA override parameter, it'll end up being "(not set)" or something like that.

The geo data, by default, comes from the IP address of the request, and again, if all your requests are coming from the same server, without using the IP override, it'll look like they're all coming from the same place.


Neil Donnell

unread,
Nov 11, 2015, 6:17:03 PM11/11/15
to Philip Walton, google-analytics-measurement-protocol
Do you know how can we override this with the values that are coming from the client device?

Philip Walton

unread,
Nov 11, 2015, 7:07:32 PM11/11/15
to Neil Donnell, google-analytics-measurement-protocol
You just extract the data from the client's request headers. The basic strategy is outlined in this developer guide under the section "Proxy Server":

Neil Donnell

unread,
Nov 12, 2015, 3:33:16 AM11/12/15
to Philip Walton, google-analytics-measurement-protocol

The problem here though is that the client is talking directly to GA and not passing this information through the backend.

Alex Whittaker

unread,
Nov 12, 2015, 4:26:24 AM11/12/15
to google-analytics-measurement-protocol
A little more background on this one:

The game is using the parse.com back-end from which I have written a GA tracking module, the key parts of the code are the event builders that put together the payload:

var cEventBuilders = {
core: function(cEvent) {
var cData = {
v: 1,
tid: cConfig.id,
ds: 'cloud',
an: cConfig.appName,
aid: cConfig.appID
};

if (Parse.User.current() !== null) {
cData.uid = Parse.User.current().id;
cData.geoid = '';
cData.uip = '';
} else {
cData.cid = 555;
}
return cData;
},
event: function(cEvent) {
var cData = cEventBuilders.core(cEvent);

cData.t = cEvent.type;
cData.ec = cEvent.data.category;
cData.ea = cEvent.data.action;
if (cEvent.data.label !== undefined) cData.el = cEvent.data.label;
if (cEvent.data.value !== undefined) cData.ev = cEvent.data.value;
return cData;
},
timing: function(cEvent) {
var cData = cEventBuilders.core(cEvent);

cData.t = cEvent.type;
cData.utc = cEvent.data.category;
cData.utv = cEvent.data.variable;
cData.utt = cEvent.data.time;
cData.utl = cEvent.data.label;
return cData;
}
};

Usually there is a Parse.User set so the cid of 555 is only set for server jobs that are not associated with a user session. The payload looks like this:

{"v":1,"tid":"UA-XXXXXXXX-1","ds":"cloud","an":"AppName","aid":"com.example.appName","uid":"lpoQI23IO9","geoid":"","uip":"","t":"timing","utc":"function_success","utv":"game_GetTeam","utt":1877,"utl":"duration"}
{"v":1,"tid":"UA-XXXXXXXX-1","ds":"cloud","an":"AppName","aid":"com.example.appName","uid":"lpoQI23IO9","geoid":"","uip":"","t":"event","ec":"function_success","ea":"game_GetTeam"}

For a job without any user credentials we send a payload like this:

{"v":1,"tid":"UA-XXXXXXXX-1","ds":"cloud","an":"AppName","aid":"com.example.appName","cid":555,"t":"event","ec":"job_success","ea":"CullOldMessages"}

The client messages are sent directly to GA - they have the same clientID and we are seeing them unify their sessions - so that there is no double reporting however whilst the Geo Location seems to be correct for the country, the city appears to be overwritten by the server side reporting (with IP and geoid set to empty strings). Also the device category is being overwritten and set to Desktop.

Before we put in the session unification we were seeing double counting and the location was set to the US for all server side calls - these have now gone which suggests that the country location is correct. A hypothesis is that using the geoid set to an empty string is preventing the country getting overwritten but not the city.

I can see that a work round might be to get the client to send the server it's IP address and user agent string but that doesn't feel like a fix to me - surely session unification should make this problem go away.

Philip Walton

unread,
Nov 12, 2015, 6:20:15 PM11/12/15
to Alex Whittaker, google-analytics-measurement-protocol
Alex and Neil, all your assumptions are correct about the way things are supposed to work, which makes me think the problem is in part of your implementation that you're not showing me.

It's really hard to know for sure because I can't see exactly what you're doing or what your reports look like, but it is the case that session-level dimensions get their value from the first hit of the session, and then those values get applied to all other hits in the session. If you're seeing different values for session-level dimensions, it's probably because you're starting a new session somehow.

To test this, I sent the following three hits, in order, to a test property of mine:


The first hit would be similar to your client hit, where the geo and device type data is determined from the request headers.

The second hit adds a `ua` parameter for a different browser and the third hit adds `geoid` data for Dubai.

When I report on this data, here's what I get

BrowserCitySessionsPageviews
ChromeMountain View13

If I add the dimensions `ga:pagePath`, it looks like this:

BrowserCityPageSessionsPageviews
ChromeMountain View/foo11
ChromeMountain View/bar11
ChromeMountain View/qux11

As you can see, there is no data for Dubai, and there is no data for Firefox (the UA string I used).

There's only 1 session, and there are 3 pageviews. Since `ga:pagePath` is a hit-level dimension, it shows up separately for each pagview, but since `ga:browser` and `ga:city` are session-level dimensions, only the value from the first hit of the session is used.

If you're seeing different results than this, you're either doing something wrong (somewhere) or it's a bug and should be reported here:


I hope that helps.




--
You received this message because you are subscribed to the Google Groups "google-analytics-measurement-protocol" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-analytics-measure...@googlegroups.com.

Neil Donnell

unread,
Nov 12, 2015, 6:49:20 PM11/12/15
to Philip Walton, Alex Whittaker, google-analytics-measurement-protocol
Hi Philip,

Is there a chance that the realtime view doesn't display this correctly?  That's what we have been looking at for feedback.

Cheers,

Neil

Sent from my iPhone
You received this message because you are subscribed to a topic in the Google Groups "google-analytics-measurement-protocol" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-analytics-measurement-protocol/6b0O4m3yypc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-analytics-measure...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-analytics-measurement-protocol/CAChM%3DvpToF9Tjma9vGATLuNUE-q2hqa4F24NovxLbhmw8wbkUA%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.

Philip Walton

unread,
Nov 12, 2015, 7:19:30 PM11/12/15
to Neil Donnell, Alex Whittaker, google-analytics-measurement-protocol
Yes, in some cases (like this one, actually) the Real Time view will be different from what ultimately ends up in reports. The reason is because Real Time doesn't have a concept of a session (since it's real time and the session is currently in-progress).

For example, when I was sending those test hits, my Real Time view showed an active user in Dubai, but then the reports did not show Dubai as a city.

Neil Donnell

unread,
Nov 13, 2015, 10:21:37 AM11/13/15
to Philip Walton, Alex Whittaker, google-analytics-measurement-protocol

Thanks for your help Philip, this made a difference.

 

From: Philip Walton [mailto:philip...@google.com]

Sent: 13 November 2015 00:19
To: Neil Donnell <neil.d...@ingg.com>

Alex Whittaker

unread,
Nov 13, 2015, 10:25:36 AM11/13/15
to google-analytics-measurement-protocol
Yes, just to wrap this up - I had not set the server events to be non-interactive and consequently they were causing a somewhat obscure failure case. Also in the mix was the fact that when I tried setting the events to non-interactive it looked like there were no events coming through because the default view in realtime events is to filter events to active users only.

Many thanks,


  ..alex

On Wednesday, November 11, 2015 at 10:38:24 PM UTC, Neil Donnell wrote:
Reply all
Reply to author
Forward
0 new messages