We have a series of the following events:
- A new anonymous user lands on our website
- We set utm params and other user properties
- They make a purchase
- Server side registers the purchase and creates a user with userId.
- At this point in nodejs we pass the userId to amplitude identity and we send a “purchase event” to amplitude from the server.
- After that, client side receives the userId and amplitude web sdk also sets userId
The problem that we run into is on step 5 the amplitude user that is attached to the “purchase event” is missing the utm and other properties that we set on step 1.
My understanding is that it happens because amplitude only merges the user ids on step 6 and on step 5 amplitude knows nothing about a user with “userId” hence no fields.
Question: What is the best way to make sure the “purchase event” has all the properties of the initial anonymous users? How do we tell amplitude nodejs sdk that we are dealing with a specific anonymous user?
Seems like we need to pass deviceId and amplitudeId to the server and then set them in the amplitude nodejs sdk, but there seem to be no way to read and set both of those ids through the SDKs, unless I missed it.
Any help on that is much appreciated!
Thanks,
Artem