<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>geekadin &#187; Coding</title>
	<atom:link href="http://geekadin.com/category/coding/feed/" rel="self" type="application/rss+xml" />
	<link>http://geekadin.com</link>
	<description>geek.life</description>
	<lastBuildDate>Wed, 28 Jul 2010 23:05:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3070</generator>
		<item>
		<title>Quick and Dirty Link Hider and Counter</title>
		<link>http://geekadin.com/coding/quick-and-dirty-link-hider-and-counter/</link>
		<comments>http://geekadin.com/coding/quick-and-dirty-link-hider-and-counter/#comments</comments>
		<pubDate>Fri, 05 Oct 2007 00:20:08 +0000</pubDate>
		<dc:creator>Jon</dc:creator>
				<category><![CDATA[Coding]]></category>

		<guid isPermaLink="false">http://geekadin.com/quick-and-dirty-link-hider-and-counter/</guid>
		<description><![CDATA[I&#8217;ve been doing some affiliate marketing recently and was in need of a script that could hide my affiliate link and also give me a count of the times it was clicked so I could calculate stuff like conversion rates and such accurately. I looked around for one a lot but couldn&#8217;t find one so [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p></p><p>I&#8217;ve been doing some affiliate marketing recently and was in need of a script that could hide my affiliate link and also give me a count of the times it was clicked so I could calculate stuff like conversion rates and such accurately. I looked around for one a lot but couldn&#8217;t find one so I went ahead and made one myself. As I&#8217;m currently rather new to PHP this is rather dirty but it works.</p>
<p>I thought I&#8217;d share it as well. Basically it makes a text file in the directory that you put it in that just has the number of clicks through this link, then it forwards the user on to the link. I recommend putting it in a directory like www.yourdomain.com/recommends/link.php and linking to that. I make a separate one for each link I want to track. In the future I plan to upgrade this to provide more tracking and such but it&#8217;s pretty useful now so hopefully someone can put it to use.</p>
<pre class="brush: php;">

&lt;?php

// customize these things
$linkCountFile = '&lt;counter file name&gt;.txt';
$linkToGo = '&lt;your link here&gt;';

// leave this alone
$clickCount = 0;

if (file_exists($linkCountFile)) {

$fh = fopen($linkCountFile, 'r');
$clickCount = fgets($fh);
fclose($fh);
}

$clickCount++;

$fh = fopen($linkCountFile, 'w');

fwrite($fh, $clickCount);

//echo &quot;clicks: $clickCount&lt;br&gt;&quot;;
//echo &quot;going to: $linkToGo&quot;;

header( &quot;Location: $linkToGo&quot; ) ;
?&gt;
</pre>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://geekadin.com/coding/quick-and-dirty-link-hider-and-counter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

