aceofspace has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I'm in the process of setting up a new website. The site has a search form. Visitors can enter any search keywords to search our database for information. There are Google Adsense ads in the Search Result Page. We also log or record the search terms visitors enter.

There is one problem installing the Google AdSense Code in the Search Result Page. It is that the Google AdSense Code will cause our script to log the seach term one more time after our script has logged the entry already.

The followings will illustrate what the problem is. Let's say a visitor enter 'San Jose' in our search form to find information about 'San Jose' in our database. Our script will record or log 'San Jose' in our log table, prints the Search Result page with Google AdSense Ad in it, but the Google AdSense Code will cause our script to record 'San Jose' again in the table, causing 2 entries of 'San Jose' in our log table.

I'm curious if any of you has experienced similar problems? If you've, how do you solve the problem?

Background information of the site:

Server: Linus
Programming language: Perl
Database: MySql
  • Comment on Google AdSense Code causes double entries of search terms in the log table

Replies are listed 'Best First'.
Re: Google AdSense Code cause double entries of search terms in the log table
by Corion (Patriarch) on Dec 21, 2010 at 07:56 UTC

    How do you expect us to diagnose the problem if you show neither the code nor the log entries ?

    Most likely, your script logs the search twice because it's accessed twice, maybe due to some wonky URL setup in your web server.

    I advise you to divide the number of hits by two unless you come up with more information relevant to the problem.

      Our log table has an id entry to indicate the ip and time that made the entries.

      The second entry consistently has an ip (66.249.71.196) like the following:

      66.249.71.196-1292911017

      1292911017 is the unix time that made the entry.

      ISP for 66.249.71.196 is Google.

      I've also tested without using Google AdSense Code. It does not have double entries when no Google AdSense Code is used in the Search Result Page.

      From the above evidence, the second entry definitely came from the Google AdSense Code.

      It is not like you mentioned due to the script accessed twice, maybe due to some wonky URL setup in my web server.

        If you want to ignore searches that come from Google, why not simply do so?