Forum Moderators: coopster
I'm an affliate website owner and will be using Clicktracks for tracking and reporting, etc. However as an affiliate the main website cart system which the customers see is obviously not my website and I cannot therefore track which buttons are being pressed. Clicktracks has posted a topic on this as follows:
Q: How can I count clicks on my site that lead to another site?
A: When a user clicks to a page that is outside your site the request shows up in the logfile of target page, and not within your site. If your site makes extensive use of such hyperlinks for partner sites or affiliate programs, you may be missing significant data from the website. This problem can be solved by modifying the links pointing to external sites to instead point to an internal page that then redirects to the external site. The internal page will appear in the logfile and be counted, and the user will see no difference in the site use.
Here's how this is done. This examples uses the PHP website scripting language. ASP and other scripting will work in a very similar manner :
First, modify the external links. If your site is 'www.somesite1.com' and the external site is 'www.somesite2.com' then the HREFs will be
<A href='http://www.somesite2.com'>.
Modify these links to :
<A href='exit.php?url=www.somesite2.com'>.
Do this for each external link.
The second step is to write the PHP page for exit.php. It's about as simple as PHP gets :
<?php
$url = @$_GET["url"];
header("Location: [".$url);...] exit;
?>
This single line outputs the HTTP header telling the browser to redirect to the target URL. Make sure this is at the top of the exit.php file.
Finally, make sure ClickTracks does not mask the URL parameter. Open 'Dynamic Page Parameters' and uncheck the box for the 'url' parameter if necessary.
Now here is the problem.
When I try the above and click on one of the buttons with the modified link it doesn't work. I can see that it goes to the cart system in my browser window but displays an error saying 'Sorry that category was not found'. He is the link BEFORE is was modified (domain names have been changed for privacy reasons)
www.maincartdomain.co.uk/modules/shop/noframes_ranges.asp?rangeid=4&catid=2&sheet=&dealer=382
And here is the modified link:
www.MyDomainName.com/exit.php?
url=www.maincartdomain.co.uk/modules/shop/noframes_ranges.asp?rangeid=4&catid=2&sheet=&dealer=382
The exit.php file resides in the webroot folder on my web hosters server.
If I modify the link to:
www.MyDomainName.com/exit.php?url=www.maincartdomain.co.uk
All works okay in the sense that my suppliers website loads in my framset. So it would appear that not all of the correct link is getting through.
Can anyone help?
TIA
[edited by: jatar_k at 3:27 pm (utc) on Oct. 23, 2003]
[edit reason] fixed sidescroll - broke link [/edit]
Seems like you should use rawurlencode() to set up a link that has parameters. That way the GET will not be confused by the extra "?" and "&"s in the modified url. Once you get the url in the exit page you'll have to use rawurldecode() to get it back to normal and put it in the header.
I think that will work but maybe somebody else has a better solution.