Client id bug
It looks like when a user visits an amp page for the first time from a viewer, a new client id (say id1) is generated for them. This id is stored and managed by the viewer.
if the user then visits a page on cdn.ampproject.org and if a client id (say id2) is generated in this viewer-less scenario, it is stored in localStorage.
When the user goes back to a page that is hosted in the viewer, id1 should be used as client id but it looks like id2 is being used currently.
cc @cramforce
@avimehta @rudygalfi This is easy to change, but it solves one case of double-counting.
It won't help much with double-counting because we still have two ids. one for viewer and viewer-less case. But the fix is still welcome :).
Well, it makes a user that went to cdn.ampproject.org once be counted as the same user for all viewers.
that is true. I am not sure how I feel about this. After talking to @btownsend, it seemed like this should be fine. Re closing this bug without any changes is fine for now. If something comes up later, we can revisit.
Just want to make sure I'm following this correctly. The client ID is intended to be unique per origin and per analytics endpoint, but NOT per viewer:
- (A) Pub P1, Endpoint E1, Viewer V1 ==> Client id CID1
- (B) Pub P1, Endpoint E2, Viewer V1 ==> Client id CID2
- (C) Pub P2, Endpoint E1, No viewer ==> Client id CID2
- (D) Pub P2, Endpoint E1, Viewer V1 ==> Client id CID2
- (E) Pub P2, Endpoint E1, Viewer V2 ==> Client id CID2
It sounds like if (C) happens first, followed by (D) or (E), you'd get another client id CID3, at least the first time you do (D) or (E) in their respective viewers. Is this correct?
@rudygalfi your example is correct.
Looking at this again, I understood the implementation differently. @cramforce can you correct me where I am wrong?
(A) Pub P1, Endpoint E1, Viewer V1 ==> Client id CID1 (B) Pub P1, Endpoint E2, Viewer V1 ==> Client id CID2 (C) Pub P2, Endpoint E1, No viewer ==> Client id CID3 (D) Pub P2, Endpoint E1, Viewer V1 ==> Client id CID3 or CID4 (E) Pub P2, Endpoint E1, Viewer V2 ==> Client id CID3 or CID4
The bug is about the CID for (D) and (E). Depending on the sequence of visits, the CID for (D) and (E) changes. See below:
If the sequence is (C) => (D) => (E), All the client ids are CID3. If the sequence is (D) => (C) => (D), (D) returns CID4 first, then (C) returns CID3 then (D) returns CID3.
In the second sequence, (D) returns CID4 first and returns CID3 on second visit.
Closing as WAI