Reputation: 1
I'm working on a freelance project and would like to ask for some help.
Problem context:
I created a nodejs server for my client's website. His website is basically a landing page that sells a product. When the person enters this landing page, they make a request to my server and, based on some business rules, return personalized data to the frontend, such as a personalized price for that product, etc...
The problem:
When a person enters the landing page, they can come from different sources (Facebook, Instagram, etc.). When a person enters the landing page I use javascript's document.referrer to identify where that person is coming from and send this information to my server. The problem is that document.referrer doesn't work 100%, in several cases the person clicks on his ad on Facebook Ads and my document.referrer comes with an empty string and not with the Facebook reference... The same happens with his ads on Instagram... My question is: Is there a more reliable way and with a smaller margin of error that I can get the reference of where the user is coming from before accessing the landing page?
Comments:
It is not necessary to identify all sources, the most important are Facebook and Instagram.
Due to some business rules of the application I cannot create different sites or routes in the application for, for example: "meusite.com/facebook" this route will only be for people who come from Facebook, etc...
I also can't use a queryparam, such as: "mysite.com/?source=facebook"
Both cases cannot be used because I need to be 100% sure that the person came from Facebook. In your scenario, if a person clicks on the link meusite.com/?source=facebook on WhatsApp, for example, it will be considered that they came from Facebook, even if they came from WhatsApp. And for some reasons of my client's business rules and the way he works today, this case will happen quite frequently. In my case, I need the person to go to meusite.com and I can identify whether they came from Facebook, Instagram, etc... without a link or parameter in the specific url and which has greater precision than document.referrer
Thanks for your attention >:)
I didn't find any other solution other than using document.referrer or using a custom route/page.
Upvotes: -1
Views: 47
Reputation: 35
Reading your comment about some services that would do that, the only possible solution I see for those to work is to be integrated in many websites (which is likely not possible in your case).
I believe this is what google does with its "analytics" cookies. The idea is pretty simple: when a user visits a website, that site will update the cookie with any data that might be considered relevant (by google), and in exchange, the owner can have access to many informations about the traffic on his website. Basically, every user of the analytics service shares the data of their customers with anyone else using the same service, and that works because many websites integrates this service and is willing to edit this cookie on the user's browser.
According to what they say here, it might even be able to recognise what app a user is coming from (in case "source" browser changes during the user's navigation).
So, to answer your question, the only "more reliable" way that might exist is to use those services, unfortunately.
Upvotes: 0