简体   繁体   English

使用Java找出用户来自哪个网站

[英]Finding out which website a user is coming from using Javascript

So using javascript, I'd like to know if there's a way to find out where a user is coming from, save it to a variable and use that address later. 因此,使用JavaScript,我想知道是否有一种方法可以找出用户的来源,将其保存到变量中,然后再使用该地址。

For example: I give an ad banner to various websites, and when a user clicks on the banner, they come to my online store, and if they buy anything, I want to know which website they came from, and how much they spent shopping on my website. 例如:我给各个网站提供了一个广告横幅,当用户单击该横幅时,他们来到了我的在线商店,如果他们购买了任何东西,我想知道他们来自哪个网站,以及他们花了多少钱购物在我的网站上。

Is there a way to do that with javascript? 有没有办法用JavaScript做到这一点?

Is there a way to use a cookie to store the inbound url, and then after someone buys something, just email that someone coming from "websiteHere.com" bought something on your website? 有没有一种使用cookie来存储入站URL的方法,然后在某人买了东西之后,仅通过电子邮件发送电子邮件,称来自“ websiteHere.com”的某人在您的网站上买了东西? and then the cookie gets deleted, or is that bad practice? 然后删除Cookie,还是这是错误的做法?

Typically you'd generate a unique URL for each ad banner. 通常,您会为每个广告横幅生成一个唯一的URL。

mysite.com/?bannerid=123456

Then your e-commerce software would associate that banner ID with the user session and record this as part of the transaction. 然后,您的电子商务软件会将该横幅ID与用户会话相关联,并将其记录为交易的一部分。 You should be doing this on the server anyway, not with JavaScript. 无论如何,您都应该在服务器上执行此操作,而不是使用JavaScript。

Captain, assuming you are trying to market your store using online banner, for now what i can think of is when you provide them your banner, you will have to give them some information to link that banner to your online store, all you have to do is to tell them to add their website information like ( source='www.myfriendwebsite.com' OR a banner id ) into the link that they are clicking on. 机长,假设您尝试使用在线横幅营销您的商店,那么现在我能想到的是,当您向他们提供横幅时,您将必须向他们提供一些信息以将该横幅链接到您的在线商店,要做的是告诉他们将其网站信息(例如(source ='www.myfriendwebsite.com' 或横幅ID )添加到他们单击的链接中。 Following is just an example.. 以下仅是示例。

<a href="www.myawsomeonlinestore.com?source='www.myfriendwebsite.com'"><img src="onlinestorebanner.gif"></a>

Now the key is you have to track their clicks, if you can successfully track their clicks like the way i mentioned above, you know exactly what your user is doing, then you build a logic in your program to calculate how much they bought or whatever ... 现在的关键是您必须跟踪他们的点击,如果您能够像我上面提到的那样成功地跟踪他们的点击,您确切地知道用户在做什么,那么您就可以在程序中构建一个逻辑来计算他们购买了多少商品或其他...

If i can think of a better solution, i will update my post 如果我能想到更好的解决方案,我将更新我的帖子

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM