开发者

Redirect visitor and create new referrer info? (some PHP)

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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜