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:
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.
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