Jump to content

Cloak and Track a Link when using a variable url


vistavision

Recommended Posts

Hi everybody,

 

I want to cloak my affiliate links or mask it so it looks like a pretty url. Also if possible, I want to track the clicked link with Google Analytics so I think I need a page where I can log the click.

 

I found lots of information but not for the situation I have. I get my links from my database like this:

echo '<a href="'.$info['url'].'">the link</a>';

How can I accomplish this? So I need a url like www.mydomain.com/click and when a user click on the link the get a new page with a tracking code and a redirect script to the right url.

 

Thanks so much for the help!

 

Kind regards,

Mark

Let's assume your links are stored in a table with an ID, the URL and a Text description. You can create your links like this:

 

echo "<a href='affiliate.php?id={$row['id']}'>{$row['text']}</a>';

 

Then create a page for affiliate.php. On that page you would take the ID passed on the query string and run a query to get the URL. Then you can do whatever logging of the click that you want to perform. Lastly, you would use a header() function to redirect the user to the URL.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.