Link to home
Start Free TrialLog in
Avatar of tjyoung
tjyoung

asked on

How to retrieve a cookie set on our one site when the user visits one of our other sites?

Hi,
Trying to figure out how this could work if at all?
On our main site only, we are dropping a cookie on the users device 'CRef' - which is a uuid of that user in our CRM so later if they visit our site, we are made aware they are actively on it. That all works great.

I'm trying to figure out how to extend that to our secondary sites? So if that same user we dropped the cookie on after having visited our main site, visits one of our other sites, we can check for that same cookie, and alert us they are on our 'other site'.

We have access to our secondary sites to place a .js script link back to our main site, but I'm in the dark on how the cookie works/restrictions etc.

Doable?
Avatar of Sam Jacobs
Sam Jacobs
Flag of United States of America image

You can set a cookie that can be read by multiple sites as long as they are part of the same domain, if you add the domain to the cookie, e.g.:
Set-Cookie: <cookie-name>=<cookie-value>; Path=/; Domain=<domain-value>;

Open in new window


Avatar of tjyoung
tjyoung

ASKER

Hi,
Its a little bit the other way around: I want to set the cookie on our main site and when the user visits 'the other site' I want our main site to know about it.
I think what you are saying is 'the other site' can read the cookie I set on the main site.
I hope to read the cookie when the user is on 'the other site' and let our main site know they are on the other site
Make sense?

Or are you saying I could add the secondary domains to the cookie? so the main site I add to the domain in the cookie, plus the domains of the other sites?

I could be totally confused lol
if these are CRM sites where a user is logging in then the best option is to share the database or at least one of the databases.

if you have a table that tracks logins for instance you'll know that user one logged into the site at a specific time and you'll also know that that same user logged into your other site at a specific date and time and that's what you can use for cross-referencing.
Avatar of tjyoung

ASKER

Unfortunately we can't share at all. The way we know who the person is, is we are sending a video landing directly to that person that is using essentially a 'purl' url. So we know in our case that "Jim Smith" is watching the video, since he is the only one that knows the url.

We drop the CRef cookie on his device and now when he visits the rest of our dealer group site at anytime we are made aware (we sell cars so its handy to know if they are in the market, because they are viewing inventory)

So that part is great. But now I need to know if he may be looking at inventory on our dealer specific site

Avatar of tjyoung

ASKER

The 'dealer specific sites' we don't own but they will place a .js file on the sites for us.
So can I read a cookie that originated from our main dealer group site, on a 'dealer specific' site.
Different domain
You can only have one domain in a cookie, so they all must be part of the same domain, for example:
site1.domain.com
site2.domain.com
... are all part of the domain.com domain.

However, if you are trying to track whether a user is currently on another site, then you would need to use a database to track when the user logs on/off the other site, as Scott mentioned.

Avatar of tjyoung

ASKER

Seems like facebook can place a pixel on your site and follow someone? seems like a similiar approach to what I'm trying to devise :)
If they place a .js file on their site, then you could add code (via jQuery) to let you know when they initially get to that site, but the use may leave the site 5 seconds later, and would have no way of knowing that.
Avatar of tjyoung

ASKER

Thanks Sam, I was hoping we could magically follow the user on the secondary site reading the cookie each time the user loads a page like we do on our main site. That secondary site page loads our .js file, we get the cookie value and can determine the page they are on. The cookie value we check within our CRM and voila: "jim is on www.otherdomain.com and is looking at used cars there"
@tjyoung ... I'm doing a bit more research, and it appears that one can track users by using third party cookies. See here for an explanation: https://javascript.info/cookie, (see Appendix: Third Party Cookies) which seems to discuss just your case.
Avatar of tjyoung

ASKER

I see that. Seems like the same idea, but very confusing to make heads/tails out of
Yes, it certainly is. Sorry I don't have any more information. I haven't used 3rd party cookies before.
Here is another site discussing them: https://iq.opengenus.org/third-party-cookies/
ASKER CERTIFIED SOLUTION
Avatar of gr8gonzo
gr8gonzo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial