0

We have two websites - one programmed in .net with no login required. Our ecommerce site is located on a different server and does have login capabilities. One is www.website.com the other is shop.website.com (same domain)

Because of what my company sells and the services it offers, we would like to know the approximate location of each visitor. However, we only want to ask them once - not when they switch between our two sites.

Is there a way to pass home store location (or some other piece of information) between our two sites that will work everywhere (mobile/desktop/cross-browser). What I am finding is while it may be possible, I don't know the best/easiest/most reliable way.

jpieps
  • 19
  • 2
  • The best and most reliable way is to store this in a database. That is the best way. And I would probably combine this with so user tracking like "anonymous sessions" of some sort. The thing is that the problem is a little too broad at this point to give you a specific solution.... – Jonathan Alfaro Mar 30 '20 at 19:04

1 Answers1

0

Depends on whether you just need to know the location temporarily (session) or you need the historical data.

In general, the easiest way will be to use cookies to identify the user. Since your second website is a sub-domain, you can enable sharing of cookies between the websites. You can check how to do that here: Share cookie between subdomain and domain

If you need to persist historical data then:

  1. If there is no need for the data to be used in your application code: Consider using a service such as Google Analytics. No need to reinvent the wheel.
  2. If you want to actively use the data in your application code: Persist the location data in your database, preferably one dedicated for this purpose.

In case you would be interested how Google uses cookies to track users, this article explains it quite nicely: https://www.bounteous.com/insights/2019/12/23/how-google-analytics-uses-cookies-identify-users/?lang=en-ca

Andrej Lucansky
  • 615
  • 7
  • 15