Second Page Poaching Part 2: Data Collection Code Snippets
Below is a basic beacon-receiver method for collecting the Second Page Poaching data. You could, of course, simply include the PHP directly on your page and handle the entire thing internally. This method, while a little more exposed, would allow you to develop one system to crunch numbers and do the rank-checking remotely, so as not to disturb the machines dedicated to page-serving.
The Javascript Include
The simple Javascript Include determines whether or not the visitor to your page has come from the 2nd page of a Google search result and, if so, generates a 1px by 1px image that is actually a beacon calling a piece of PHP.
The PHP Receiver
The beacon code is quite simple. It strips out the query from the Google search result in the original page referrer. It then inserts both that and the landing page into a basic table comprised of 3 fields (id: int auto-inc, keyword: varchar(255), landingpage: varchar(255). You may also want to collect the IP address at this point to prevent data manipulation
Definately worth adding that layer of abstraction, if your serving a lot of pages scripts like this can cause umpteen issues.