1

I wish to use the Google Analytics Measurement Protocol to supplement the information GA stores about a visitor that was already constructed client side, using the GA tag. I might want to set a Custom Dimension for a user, or to record an event, or something else.

In my case, I can store and pass the client ID (from the _ga cookie) to make sure that GA recognises that this is the same user that was seen on the Web.

However, from experimentation, it seems to me that perhaps both the IP address of the user as well as the user-agent of the user needs also to be passed to ensure that GA treats all of this as a single visitor.

If I don't pass these, then it seems from looking at the real time dashboard, that GA thinks two separate users are active on my test site, where if I do pass them, it thinks there is only one user (and that's what I want).

I'd really rather not store the user IP address, and I would have thought that the user agent was not needed either, although I have no problem with storing that if required.

Does anyone know for sure? Is it perhaps just an issue with the realtime dashboard, and regular reports are not affected (I haven't waited long enough to see the results in the regular reports).

Thanks

  • You need to provide the [`uid`](https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#uid) parameter. The data will join on this field for a given user. – Matt Jan 03 '18 at 22:01
  • Thanks, but isn't uid used to "stitch" across devices based on a known person identifier? Since you only get one uid, I don't want to use it just to make the measurement protocol work when I already have the client id. Or to put it another way, if I don't have a uid from the tag, and if this is not a known visitor, what do you suggest using for the uid? – Mark Reddin Jan 05 '18 at 10:11
  • If you don't need the IP you can always use the AnonymizeIP in both tracking and payload data, this might do as workaround. – F. Leone Jan 05 '18 at 10:26

1 Answers1

0

To answer my own question, as long as the value of the cid being passed in the measurement protocol agrees with the value of the cid parameter being passed in the tag, GA will see a single visitor in both realtime and regular reports. I am not sure why my previous experimentation yielded a different result, I think I'd made a mistake previously.