I need to track anonymous users with enabled cookies.
Basically, they will go through the site, interact with it, and I would like to give them the best possible experience without requiring actual registration. Later on, if they want, they can register and their site activity will be tied to their new account.
Something like Stackoverflow but with the difference that I expect that majority of my users won't actually register but occasionally just comeback.
So, I don't want to create a bunch of dummy records in the Users table. And since I need it just for one table, I was thinking about something like this:
VoteHistory table
Id TrackingToken VotingData
1 100 ...
2 100 ...
3 101 ...
4 102 ...
Users table
Id TrackingToken OtherUsersColumns
1 100 ...
TrackingTokens table
LastTrackingToken
102
I would increment a LastTrackingToken integer field and simply add that value to the users cookie and track his voting activity with it. Then, if he decides to register, I would simply add his cookie TrackingToken value to his Users record.
Initially I was thinking about a Guid/uniqueidentifier but since the voting table will be very large and I will need to query it, I'm worried about indexing the uniqueidentifier field.
So, the questions are (sorry for 3 sub-questions, but they are so related and I think the context is important, so I don't want to duplicate the question and context description):
Is integer field better when it comes to performance and indexing? Have in mind that TrackingToken is not a primary key field!
Do you have some other idea how I could accomplish the scenario I outlined?
If I decide to go with the manual generation of integer TrackingTokens, what would be the best way to reliably generate/increment a new TrackingToken? Assume a lot of concurrent users will hit the database.