重定向访客并创建新的推荐人信息? (一些PHP)

发布于 2024-09-10 00:04:47 字数 1222 浏览 3 评论 0原文

我有 2 个网站 - 网站 A 是接收流量的主要“营销”网站,网站 B 是人们进行购买的网站。网站 B 的报告系统向我提供了导致购买的网站 A 的引荐 URL。

网站 A 有多种指向网站 B 的号召性用语链接,我想衡量其中哪个链接对推动销售最有效。

以下是我目前的设置:

假设您位于 siteA.com/this-page.php。通常,单击站点 B 的链接会将此页面显示为引荐来源网址。相反,指向站点 B 的链接是 siteA.com/this-page.php?link=top-banner&dest=home,其中“link”提供被单击链接的 ID,dest 是站点 BI 想要访问的页面将点击发送至。

我在网站的每个页面上都有一个 PHP 包含内容:

<?php
if (isset($_GET['link'])) {
  $qs = $_SERVER['QUERY_STRING'];
  $form_action = "/redirect.php?" . $qs;
?>

<html>
<body onload="document.forms.go.submit();">
<form method="post" action="<?php echo $form_action; ?>" name="go"></form>
</body>
</html>

<?php } else {} ?>

redirect.php 页面计算出网站 B 上的目标页面,并执行标头重定向到适当的页面。

现在这对我来说效果很好,并且推荐人在站点 B 的统计数据中正确显示。

这似乎是一个不太优雅的解决方案,而且我还遇到了一些可用性问题:

  1. 当您单击指向站点 B 的链接时,会出现明显的延迟,因为当前页面会重新加载,表单会被提交,并且访问者会被访问。重定向。

  2. 访问者到达站点 B 后,他们无法点击“后退”按钮返回站点 A。点击“后退”会将他们带到带有 ?link 参数的页面,然后他们会再次重定向。

我是一名编码新手,因此感谢您的帮助和建议。谢谢!

编辑:本质上,我在这里所做的是动态更改引荐来源网址:

  • 常规引荐来源网址:siteA.com/this-page.php
  • 更新的引荐来源网址:siteA.com/this-page.php?link=top-banner

I have 2 websites -- website A is the primary 'marketing' site that receives traffic and website B is the site where people make a purchase. Site B's reporting system provides me with the referring URL from site A that resulted in a purchase.

Site A has a variety of call to action links that go to site B, and I would like to measure which of these links is most effective at driving sales.

Here's what I currently have set up:

Let's say you're on siteA.com/this-page.php. Normally, clicking on a link to site B would show this page as the referrer. Instead, a link to site B is siteA.com/this-page.php?link=top-banner&dest=home, where 'link' provides the id for the link being clicked and dest is the page on site B I want to send the click to.

I have a PHP include on every page of the site with this:

<?php
if (isset($_GET['link'])) {
  $qs = $_SERVER['QUERY_STRING'];
  $form_action = "/redirect.php?" . $qs;
?>

<html>
<body onload="document.forms.go.submit();">
<form method="post" action="<?php echo $form_action; ?>" name="go"></form>
</body>
</html>

<?php } else {} ?>

The redirect.php page figures out the destination page on site B and does a header redirect to the appropriate page.

This works fine for me right now and the referrer shows up properly in site B's stats.

This seems like an inelegant solution and I also run into a couple of usability issues:

  1. There is a noticeable delay when you click on a link to site B, as the current page reloads, the form is submitted, and the visitor is redirected.

  2. Once the visitor arrives at site B, they can't hit the 'back' button to get back to site A. Clicking back takes them to the page with the ?link parameter and they just get redirected again.

I'm a coding novice, so your help and suggestions are appreciated. Thanks!

EDIT: In essence, what I'm doing here is changing the referrer on the fly:

  • regular referrer: siteA.com/this-page.php
  • updated referrer: siteA.com/this-page.php?link=top-banner

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

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

发布评论

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

评论(1

卷耳 2024-09-17 00:04:47

这就是流程:

siteA.com/this-page.php (which has several links, each with an identifier "id")
siteA.com/this-page.php?link=id&dest=home [referrer=siteA.com/this-page.php]
<form/javascript "forward hack">
siteA.com/redirect.php?link=id&dest=home [referrer=siteA.com/this-page.php?link=id&dest=home]
siteB.com/home [referrer=siteA.com/this-page.php?link=id&dest=home]

我不确定我是否理解你的问题。您希望引荐来源网址停留在 siteA.com/redirect.php?link=id&dest=home 而不是 siteA.com/this-page.php?link=id&dest=家?为什么?
浏览器在遵循重定向时不会更改引荐来源网址,因此您确实需要转发技巧。

我建议您做的是将链接直接链接到 redirect.php 。引荐来源网址将是 siteA.com/this-page.php 而不是 redirect.php,但我不明白为什么这是一个问题。

So this is the flow:

siteA.com/this-page.php (which has several links, each with an identifier "id")
siteA.com/this-page.php?link=id&dest=home [referrer=siteA.com/this-page.php]
<form/javascript "forward hack">
siteA.com/redirect.php?link=id&dest=home [referrer=siteA.com/this-page.php?link=id&dest=home]
siteB.com/home [referrer=siteA.com/this-page.php?link=id&dest=home]

I'm not sure I understand your question. You want the referrer to stay at siteA.com/redirect.php?link=id&dest=home and not siteA.com/this-page.php?link=id&dest=home? why?
The browser doesn't change the referrer when it follows a redirect, so you really need your forward hack.

What I suggest you do do is to have your links link to redirect.php directly. The referrer will be siteA.com/this-page.php instead of redirect.php, but I don't see why that's a problem.

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