Open tomek3e opened 1 year ago
True. Based on the docs it should be sending GA a userId of null
or "null"
(I can't tell for sure which) but in the code it looks like the plugin will ignore null or empty userId values and just leave the userId as it was before.
I guess the only workaround currently is to do a page reload, although I suppose GA would still store a cookie or value in local storage in that case so even then it could remember the old value.
Correct, even page reload will not work so I am extending the plugin to handle my use case (chrome kiosk mode - multiple users on same device):
If I don't do points 2 & 3 the subsequent events on the same device will still be associated with the same user in analytics.
Yeah looks like ga4 and ga3 plugin don't have a reset
defined like so https://github.com/DavidWells/analytics/blob/0fb5860bf2b7e2c180dbc0462c66c6bd36331fde/packages/analytics-plugin-original-source/src/index.js#L40-L43 so there isn't any cleanup action happening in them. Only the libs values are getting reset.
We'd need a reset
method defined in the plugin where u can run this logic. You can extend this in userland like so https://github.com/DavidWells/analytics/issues/67#issuecomment-664804311
Google analytics plugin does not have an implementation for reset, hence after:
analytics.reset()
userId is still being sent.