peaksandpies / universal-analytics

A node module for Google's Universal Analytics and Measurement Protocol
962 stars 147 forks source link

Analytics shows server location traffic instead of customer location #80

Open michaelhidalgo opened 7 years ago

michaelhidalgo commented 7 years ago

Hi folks, this is just a question.

I deployed an application with universal-analytics and the application was deployed into a cloud server, however when accessing the site from Costa Rica, I can see in Google Analytics that the location of the traffic is the on from server, not my remote location.

I used the same samples from this repository and I was wondering if i need to pass somehow the remote ip so it can use my location instead of the server's one.

Thanks.

sfratini commented 7 years ago

I am having the same issue however I understand this is the "expected" behavior since the requests are coming from the server and not the client (I use this in a chatbot where everything runs on the server).

It would be nice to be able to override this somehow.

jtillmann commented 7 years ago

You can, the Measurement Protocol parameter uip is meant for IP override: https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#uip

abskmj commented 6 years ago

Hi @jtillmann, does this module support passing these values to override IP and User Agent? If not, I can work of it and send you a pull request.

I'm think, these override parameters can be sent as part of visitor options. Something like this:

var visitor = ua('UA-XXXX-XX', 'CUSTOM_CLIENTID_1', {uip: "", ua: "" });
jtillmann commented 6 years ago

They can not be provided to the visitor options, they need to be provided as parameters to track calls or as persistent parameters.

abskmj commented 6 years ago

Great! I didn't see that part of the documentation. This module already supports passing override parameters.

j-mendez commented 2 years ago

Currently experiencing this issue on my fargate instance on AWS. I am setting the vistor using visitor.set("uip", ip) with the proper ip and its using my servers IP instead. I think the request headers is being declared as source of truth instead of the visitor uip.

j-mendez commented 2 years ago

@michaelhidalgo using version 0.4.23 seems not have the issue. In my case I needed to downgrade the package.

jtillmann commented 2 years ago

Could you check the debug output? There should be no difference between .4 and .5 in this regard.