Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

analytics.reset() does not reset userId in google-analytics plugin #340

Open
tomek3e opened this issue Nov 14, 2022 · 4 comments
Open

analytics.reset() does not reset userId in google-analytics plugin #340

tomek3e opened this issue Nov 14, 2022 · 4 comments

Comments

@tomek3e
Copy link

tomek3e commented Nov 14, 2022

Google analytics plugin does not have an implementation for reset, hence after:
analytics.reset()
userId is still being sent.

@dobesv
Copy link
Contributor

dobesv commented Nov 15, 2022

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.

@dobesv
Copy link
Contributor

dobesv commented Nov 15, 2022

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.

@tomek3e
Copy link
Author

tomek3e commented Nov 16, 2022

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):

  1. Set user_id to undefined.
  2. Set client_id to a new value - in google format XXX.YYY, where XXX is a random part and YYY is a unix timestamp.
  3. Clear the cookie.

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.

@DavidWells
Copy link
Owner

Yeah looks like ga4 and ga3 plugin don't have a reset defined like so

reset: ({ instance }) => {
instance.storage.removeItem(CONFIG.originalSourceKey)
instance.storage.removeItem(CONFIG.originalLandingPageKey)
}
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 #67 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants