通过url跟踪用户并避免手动篡改

发布于 2024-11-06 04:37:55 字数 137 浏览 1 评论 0原文

我想跟踪有多少人点击通过电子邮件发送的链接。

目前,我正在考虑建立一个单独的页面,通过带有 get 变量的链接调用该页面,以指示这是通过电子邮件完成的。

显然,这可以通过导航器的地址栏手动篡改。我可以使用什么方法来限制这种情况?

I'd like to keep track of how many people follow a link sent through an email.

At the moment, I'm thinking of having a separate page which is called through the link with a get variable to indicate this was done from an email.

Obviously, this can be tampered with manually through the address bar of a navigator. What approaches could I use to limit this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

み格子的夏天 2024-11-13 04:37:55

1) 使用完全不同的 URL 重定向到真实 URL:

http://www.mysite.com/emailOffer -> http://www.mysite.com/specialpage

emailOffer 会进行日志记录,然后发送一个指向真实页面(specialpage)的 Location HTTP 标头

http ://www.mysite.com/emailOffer 看起来像这样:

/* SOME LOGGING CODE GOES HERE - PROBABLY MYSQL STUFFS */
header("Location: http://www.mysite.com/specialpage");

2)添加一个 GET 参数,例如:http://www.mysite.com/specialpage?email
然后在 php 中,您可以执行以下操作: if(array_key_exists('email',$_GET)) addToCounter();

3)您可以为访问该页面并运行查询的每个人记录 HTTP Referer 标头对于包含“mail”的引荐来源网址(例如,mail.google.com、hotmail.com)

为了帮助防止篡改,您可以使该参数看起来值得:
http://www.mysite.com/specialpage?secretOffer

祝你好运! :)

PS - 抱歉我的答案格式很糟糕......

1)Use a completely different URL to redirect to the real one:

http://www.mysite.com/emailOffer -> http://www.mysite.com/specialpage

emailOffer would do the logging, and then send a Location HTTP header pointing to the real page (specialpage)

http://www.mysite.com/emailOffer would look like this:

/* SOME LOGGING CODE GOES HERE - PROBABLY MYSQL STUFFS */
header("Location: http://www.mysite.com/specialpage");

2)Add a GET parameter like: http://www.mysite.com/specialpage?email
then in php, you can do: if(array_key_exists('email',$_GET)) addToCounter();

3)You could log the HTTP Referer header for everyone who hits the page and run a query for referers containing "mail" (e.g., mail.google.com, hotmail.com)

To help prevent tampering, you could make the parameter seem worth while:
http://www.mysite.com/specialpage?secretOffer

Good luck! :)

PS - sorry for the terrible formatting of my answer...

兮子 2024-11-13 04:37:55

在大多数情况下,人们可能只使用 GET 方法,但在所有情况下,它都可以被篡改,如果一个人真的愿意,几乎每个元素都可以更改,但就告诉某人从哪里来而言,你是相当不错的很受 GET 或检查引荐来源网址的困扰,这可能非常可疑,并且您必须检查各种各样的事情。

如果您不关心他们在电子邮件中跟踪的实际链接,您可以创建一个辅助页面,该页面会点击您的计数器,不输出任何内容,并且只是重定向它们,就像

<?php
... do counter stuff ....
header('Location: http://actual.address.com/');
?>

他们的导航栏将更改为新地址 一样几乎不会注意到原来的。

In most cases people probably just use the GET method, in all cases though, it can be tampered with, pretty much every element can be changed if a person really wants to, but as far as telling where someone is going from you're pretty much stuck with GET or checking the referrer, which can be highly suspect, and you'd have to check all sorts of things.

If you aren't concerned with the actual link they're following in the email, you could create a secondary page, that hits your counter, outputs nothing, and just redirects them like

<?php
... do counter stuff ....
header('Location: http://actual.address.com/');
?>

Their navigation bar will change to the new address, and they'll barely even notice the original.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文