I have a Wix site where I need to perform an action if visitors are there for the first time, and not perform it if they’ve already visited the site previously.
I can use their IP, but this of course is not good because multiple users could share the same IP, and IPs change.
Forcing them to log in isn’t an option either because it’s way too onerous from a user-experience perspective.
You can create an ID to use for the anonymous user. Do something like this:
visitorId = Math.random().toString(36);
You can then save and retrieve the visitorId from local storage. This will be “sort of” permanent; If the user clears their browser cookies/cache, then the user will be cleared and will able to visit as a “new” anonymous user.
Thanks for the excellent advice.
I was thinking local storage too, per this link I came across.
@yisrael-wix Could you kindly detail the steps?
Where does this code go?
And then how do you save it?
And retrieve it?
I need the same but I am not sure how to implement what you wrote