Domanda

I need to track purchases on my site via a dynamic button that redirects to another sites.

The code:

<div class="buyproduct">
<a onclick="target='_blank'" href="<?php echo $this->product['from'];?>">

<img src="http://xxx.com/data/images/buy.jpg" alt="Buy!"/>                          
</a>
</div>

Everytime a user clicks on the button it redirects to another site outside mine.

For example if I click on a jeans and then in the buy button, it redirects to wrangler site.

I need to track everytime this happens and know exactly to what url the user is beeing redirected.

The site is in PHP and Javascript.

È stato utile?

Soluzione

You could create an intermediate page on your server, maybe something like (out.php). You could then redirect all traffic to the out.php page, do the processing there, and then redirect.

<a target="_blank" href="/out.php?url=<?php echo urlencode($this->product['from'])?>">
    <img src="http://xxx.com/data/images/buy.jpg" alt="Buy!"/>
</a>

out.php

<?php
$url = urldecode($_GET['url']);
/*
MySQL CODE TO PROCESS TRACKING
*/
header("Location: ".$url);
exit;?>
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top