Closed MicheleBertoli closed 8 years ago
Hey @MicheleBertoli,
Segment actually doesn't send GA the referrer data -- that's parsed and calculated automatically by the GA's own JS library they load under the hood.
You can see Segment's integration mapper code for how they process any .page()
calls and they never actually define the dr
or the document referrer anywhere:
Also in GA's docs for SPA's, they explicitly ask you not to override the referrer anyway:
https://developers.google.com/analytics/devguides/collection/analyticsjs/single-page-applications
So I'm not so sure if it is the referrer that is causing the split sessions :/
I think this might be the cause:
GA docs say that updating the location for SPA's may cause split sessions... and I can confirm that Segment is parsing the url
property of your .page()
calls and overriding the location:
Thank you very much for looking into our issue @hankim813.
I can confirm that (as we wrote in the first comment):
The cause is that Segment is always sending the original referrer with the current (updated) url.
Therefore, you are right when you say:
So I'm not so sure if it is the referrer that is causing the split sessions :/
The cause it's not the referrer itself, it's a combination between referrer and url. The problem of course exists only when the referrer is present.
Just to clarify:
Any plans to fix the issue?
@MicheleBertoli so just to be on the same page are you saying that the problem only exists when the referrer
is present when we are also setting the location
as the url
?
Hello @hankim813,
it looks like Segment is always setting the location
, even when the url
property is not present.
Because of that, when the referrer
exists, you can see a single session being attributed to two different sources, like this:
Ahh so the location is actually being set for GA here:
Hmmm the url
property should always be there when you use our .page()
call. That is automatically populated by our API. So if this issue is exclusive to SPAs, then perhaps a propose solution could be an optional setting that you can check in the GA settings that tells us if you have an SPA, and we can wrap that line 178 with a conditional logic that doesn't set the location
?
What do you think. Do you know if not setting that field at all will have any other negative effects for the data?
Thank you very much @hankim813,
the flag in the Google Analytics integration's settings sounds good.
The Google's documentation clearly says "do not update the location
", therefore we think that it wont have any negative effects.
fixed in #14
The problem
At YPlan, we found that using Segment on a Single Page Application is causing Google Analytics to break the sessions, giving us the wrong PPC vs Organic attributions. The cause is that Segment is always sending the original referrer with the current (updated) url.
How to reproduce it
We created a simple SPA with React and React Router to reproduce the problem.
Landing on the application and clicking the links (i.e. updating the url) from a different referrer (e.g. jsfiddle) with the utm parameters results in a split session:
This is the "raw" Google Analytics data sent via Segment:
Overriding the referrer
We read the documentation and we tried to override the referrer, as follows:
But we found that Segment keeps on sending the original referrer to Google Analytics:
While it's sending the right one in the
context
:Any suggestions?