Generally the best approach is to store a session token in session storage, or a cookie. Then keep a persistent cart in your database keyed off that session. Depending on what you are selling people may not care about cart persistence, or being able to start the shipping experience on one device, but keeping the data in your database let's you understand what people are interested in even if they don't checkout. It also let's you retarget people if you can capture email / other info, for instance when you have a sale on an item that was in their cart.
I am a certified trainer that likes to share my knowledge with the world.
Also, I am an adopter of continuous learning and evolving idea.
https://dev.to/wolfiton/who-am-i-3lj7
Thanks, @chris-pardy for sharing your solution and explanation of why you would choose this road to solve the problem, but I have a question:
How would you get the user info if they don't have an account and also wouldn't this be considered invasive(breach on their trust and privacy) to add the user's interest to a database without their knowledge? (the product they have put in the cart)
Also for me, GDPR is a must because I live in Europe.
How you capture email or other info is ultimately a question of what your site offers and how far you or your local laws are willing to go what it comes to sophisticated online tracking. I'm not an expert on GDPR but I believe if a user signed up for a newsletter (email only, no login) you could still use their session data to retarget them for an abbandoned cart. Using the cart data for internal analytics would be possible even without personal information, and I don't think violates the trust of your users especially if that data is anonymous.
I would also say that while building a shopping cart is pretty straightforward there are some gotchas, GDPR amongst them. You're almost always going to be better off going with an ecommerce platform than rolling your own.
I am a certified trainer that likes to share my knowledge with the world.
Also, I am an adopter of continuous learning and evolving idea.
https://dev.to/wolfiton/who-am-i-3lj7
I'm a father of four. I started out as a self-taught programmer, completed a B.S. in Computer Science and am currently employed full-time since 1998.
I also own a small mobile software company.
This is how I do it. There's no identifying information as I don't capture any personal data at that point. Their shopping cart data is cleared if they make a purchase or if the item has been in their cart for more than 30 days (I run a software shop, so if they haven't purchased by then, I figure they're not going to purchase anything). Email and user data is captured when they buy a license, at which point the information is moved out of the shopping cart and into the license service.
I am a certified trainer that likes to share my knowledge with the world.
Also, I am an adopter of continuous learning and evolving idea.
https://dev.to/wolfiton/who-am-i-3lj7
Generally the best approach is to store a session token in session storage, or a cookie. Then keep a persistent cart in your database keyed off that session. Depending on what you are selling people may not care about cart persistence, or being able to start the shipping experience on one device, but keeping the data in your database let's you understand what people are interested in even if they don't checkout. It also let's you retarget people if you can capture email / other info, for instance when you have a sale on an item that was in their cart.
Thanks, @chris-pardy for sharing your solution and explanation of why you would choose this road to solve the problem, but I have a question:
How would you get the user info if they don't have an account and also wouldn't this be considered invasive(breach on their trust and privacy) to add the user's interest to a database without their knowledge? (the product they have put in the cart)
Also for me, GDPR is a must because I live in Europe.
How you capture email or other info is ultimately a question of what your site offers and how far you or your local laws are willing to go what it comes to sophisticated online tracking. I'm not an expert on GDPR but I believe if a user signed up for a newsletter (email only, no login) you could still use their session data to retarget them for an abbandoned cart. Using the cart data for internal analytics would be possible even without personal information, and I don't think violates the trust of your users especially if that data is anonymous.
I would also say that while building a shopping cart is pretty straightforward there are some gotchas, GDPR amongst them. You're almost always going to be better off going with an ecommerce platform than rolling your own.
I have some doubts regarding this practice.
Thanks for explaining a lot more about this method and also for offering some examples of how this can be implemented, I really appreciate it.
Thanks @chris-pardy
This is how I do it. There's no identifying information as I don't capture any personal data at that point. Their shopping cart data is cleared if they make a purchase or if the item has been in their cart for more than 30 days (I run a software shop, so if they haven't purchased by then, I figure they're not going to purchase anything). Email and user data is captured when they buy a license, at which point the information is moved out of the shopping cart and into the license service.
Thanks, @chrismckay for sharing your experience and talking about in detail how you use this method to manage your software shop.
I really appreciated your thorough(detailed) response to my questions.