vistavision Posted May 22, 2014 Share Posted May 22, 2014 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 Quote Link to comment https://forums.phpfreaks.com/topic/288675-cloak-and-track-a-link-when-using-a-variable-url/ Share on other sites More sharing options...
Psycho Posted May 22, 2014 Share Posted May 22, 2014 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. Quote Link to comment https://forums.phpfreaks.com/topic/288675-cloak-and-track-a-link-when-using-a-variable-url/#findComment-1480451 Share on other sites More sharing options...
vistavision Posted May 22, 2014 Author Share Posted May 22, 2014 Hi Psycho, You Are The Best!!! Thanks so much!! This works Perfectly!!!! Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/288675-cloak-and-track-a-link-when-using-a-variable-url/#findComment-1480480 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.