analyticssegment-io

Override UserId in Segment Analytics


Basic question here related to Segment analytics. Unfortunately I haven't been able to find a good answer after a fair bit of searching so turning here.

I have a couple of analytics events that need to be logged against multiple users, e.g. "Matched"

Is there a way to override the "userId" property on a event without calling identify again (which would override the user for all future events & thus risks race conditions or blocking on analytics)?


Solution

  • This is not possible with analytics.js. If you need to send events for another userId than the one you had called .identify() with, you should use a server side library to send that event.

    All server side libraries will need a userId defined so it would be a good place to send that particular event.

    Also Segment just got a brand new community to post these questions fyi.