<?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>PHP Software Developing &#187; Statistics</title>
	<atom:link href="http://www.phpdeveloping.co.za/category/statistics/feed" rel="self" type="application/rss+xml" />
	<link>http://www.phpdeveloping.co.za</link>
	<description>for the love of PHP Development</description>
	<lastBuildDate>Tue, 29 Sep 2009 15:38:14 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Tracking website visits with a transparent GIF file</title>
		<link>http://www.phpdeveloping.co.za/statistics/tracking-website-visits-with-a-transparent-gif-file.html</link>
		<comments>http://www.phpdeveloping.co.za/statistics/tracking-website-visits-with-a-transparent-gif-file.html#comments</comments>
		<pubDate>Thu, 30 Jul 2009 14:50:19 +0000</pubDate>
		<dc:creator>chris</dc:creator>
				<category><![CDATA[Statistics]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[website tracking]]></category>

		<guid isPermaLink="false">http://www.phpdeveloping.co.za/?p=109</guid>
		<description><![CDATA[With all the fancy tracking and web analytics software out there, you&#8217;d wonder why someone would still want to have their own tracking functionality on a website.  I find it easier to customize a little script than to figure out how to get it working in the analytics software.  Sometimes you really just [...]]]></description>
			<content:encoded><![CDATA[<p>With all the fancy tracking and web analytics software out there, you&#8217;d wonder why someone would still want to have their own tracking functionality on a website.  I find it easier to customize a little script than to figure out how to get it working in the analytics software.  Sometimes you really just want something simple done, and don&#8217;t want to go through all the effort to figure it out.</p>
<p>Here is a handy little script you can use.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
  <span style="color: #666666; font-style: italic;">//saves ip address and timestamp</span>
  <span style="color: #000088;">$str</span><span style="color: #339933;">=</span><span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Y-m-d H:i:s&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;: &quot;</span><span style="color: #339933;">.</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REMOTE_ADDR'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
  <span style="color: #990000;">file_put_contents</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ip_list.txt&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$str</span><span style="color: #339933;">,</span> FILE_APPEND<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;content-type: image/gif&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #666666; font-style: italic;">//43byte 1x1 transparent pixel gif</span>
  <span style="color: #b1b100;">echo</span> <span style="color: #990000;">base64_decode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>What the above does is simply logs the IP address of the site visitor and the time they visited to a plan text file in the root directory.  It then displays a 1&#215;1 pixel transparent GIF file to the browser.  </p>
<p>Why the output of a GIF file?  So that you can in any of your HTML documents just put <img src=script.php /> and it will call the script and display a transparent GIF.  So it won&#8217;t affect the way your website is being displayed, but it will still record the visitor&#8217;s details.  It also doesn&#8217;t rely on javascript, which is always a plus for me.</p>
<p>You can expand the script even more by changing it to include more statistics.  You can make it as complex or as simple as possible.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpdeveloping.co.za/statistics/tracking-website-visits-with-a-transparent-gif-file.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
