I developed a mobile web application using nodeJS. All users have an access to data(foods,menus etc) without authentication. They can list products, like them, or mark them as a favorite ..etc What I want is giving them unique IDs (on first visit) to recognize them on every time they visit and track their actions by storing those actions in my database I want that because when they are revisit my app, I'm gonna say "You have marked 3 products as a favorite this month!" or "Apperantly you like hamburgers (listed hamburger category 22 times)
In short, when user visiting my web app for the first time
- Define (or assign) unique ID and store the ID on client-side
when user visiting my web app second time
- Check if there is any ID on client-side storage
If its true then list the users recent activities for example;
var uID = "ID data on client-side." db.users.findOne({ userID: uID }, function(err, user){ if(err){ res.send("you are here for the first time!"); // >>> create new unique ID HERE and assign it to the user !!<<< } else { res.send("you were here before"); // already have an ID, go on } })
Quick Note: ID must be there all the time (on client-side) until user remove it somehow.