When a visitor subscribes to web push notifications on your website before logging in or creating an account, they are initially registered as an anonymous subscriber. By default, this anonymous subscriber is identified by a unique device identifier (Hardware ID - HWID).
To associate this anonymous subscription with a known user after they log in or register, you can update their subscriber profile using the api.registerUser()
method from the Web SDK.
Here's how:
-
Anonymous Subscription: A user subscribes to push notifications while not logged in. Their
UserID
on the platform is automatically set to their device's HWID. - User Authentication: The user logs into their account or registers a new one on your website.
-
Update UserID: Once the user is authenticated, call the
api.registerUser()
method. Pass the user's actual unique identifier (e.g., their customer ID from your database) as an argument to this method.
Note: The// Call this function after the user successfully logs in or registers. // Replace 'YOUR_USER_ID' with the actual unique ID for the authenticated user. api.registerUser('YOUR_USER_ID');
api
object and its methods might be accessed differently depending on how you've initialized the Web SDK on your page (e.g.,Pushwoosh.api.registerUser(...)
or via another SDK object). Please refer to your specific integration or the official Web SDK documentation if this exact syntax does not work in your setup.
This action will update the UserID
for that device/subscription on the platform, changing it from the initial HWID to the YOUR_USER_ID
you provide. The existing subscription will then be associated with the identified user, enabling targeted messaging based on their user profile.
For more details on the underlying API functionality, you can refer to the User Centric API documentation.
Comments
0 comments
Please sign in to leave a comment.