Hello, I need help solving an issue I've been tryi...
# support
g
Hello, I need help solving an issue I've been trying to solve for a while now. So, How do i merge the events of two anonymousIds together? We still don't have an userId as the user didn't login yet but we have two different anonymousIds from different platforms for the same user - we need to merge the events.
m
Hey There! šŸ‘‹ Your message has been received by the RudderStack team. Our standard customer support hours are 9-6 PM EST, but we will forward this request to your Technical Account Manager, and they will get back to you shortly. Please use the thread for any additional comments.
Hi Nishanth, where do you want to stitch the anonymousIds together?
If it is in a warehouse, you can check this out. https://github.com/rudderlabs/dbt-id-stitching
g
we wan to stitch them in Amplitude @shy-kite-21035
let me give you an example for better undersatnding. • a user(not logged-in) is on our website and wanders along some of the stuff, so by default RS creates an anonymousId(device_id) , let's call this 'A' • we are sending some communications to the users by create an anonymousId in the backend and attaching that to the url we send in the comm. Now when the user lands on our site through that url(with param), we create an event in RS using this anounymousID(call it 'B') and oveerride. • now we want to join these two so that we can now track the previous events(A) and the next events(B) untill the use signsup and we can use the user_id.
is there a way to accomplish this through RS JS API? @shy-kite-21035
m
Are you making any backend calls for this user? What is the backend you are using?
g
next JS
b
@great-lizard-94116 how are you sending communications? Do you have the users email address/phone number, or is it ā€œin-appā€ communication?
m
The way I envision this is 1. A user browses your and RudderStack creates an anonymous Id "frontend_anon_id_1". 2. This event information is sent to your backend (maybe use the Node JS SDK). You create a backend event identifier, called "backend_anon_id". You then make an alias call from the backend i.e. rudderanalytics.alias("backend_anon_id", "frontend_anon_id_1"). 3. From the front-end, now you can override the front-end anonymous id ("frontend_anon_id_1" or some-other id "frontend_anon_id_2", if they use a different browser) with the "backend_anon_id" and send events to Amplitude. Alternately you can do the following 1. A user browses your and RudderStack creates an anonymous Id "frontend_anon_id_1". 2. Once the backend responds with the "backend_anon_id", set this id as the user_id, using the Identify call. Both the above methods should work, but the first approach would be useful even if the customer changes the browser when he gets the url response.
b
Yes, exactly - you need to stamp the backend anonymousid on the front end. You could use alias or a basic identify call with the new value could work as well
g
And what shall we do when the user signs up and we have a actual user_id? we currently identify(user_id, anonymous_id) but my hunch is if we already ideantify(frontend_anon_id_1, backend_anon_id) when we do identify(user_id, frontend_anon_id_1) this won't patch up all the events togeather
m
Hi, So when are you making the Identify call. This should be after the user sign in is complete right. You seem to have 3 identifiers here - RudderStack Anonymous id (frontend_anon_id_1) - User yet to sign up - Backend Anonymous id (backend_anon_id) - User yet to sign up - Backend userId (userId) - User has signed in with his email/phone_number and the userId is the Database userId. Since you have these 3 identifiers, to map all three, you may need an alias call. You can do this alais call from the front_end also like this. alias(frontend_anon_⁣id_1, backend_⁣anon_id). When the user finally logs in you can set his userId, using the identify call.
gratitude thank you 1
g
Awesome! let me try this. Thank you