Google Adsense causing problems

Discussion in 'Software' started by msteinblock, Jun 15, 2005.

  1. msteinblock

    msteinblock Private E-2

    I have a site using Google Adsense. On some pages, I have php scripting that inserts data into sql, mainly for tracking how many times a photo have been viewed, etc. Since day one, I have noticed a problem of double entries. Each time you view a photo, the count increases by two. Just today, after a lot of headaches, I found the problem, Google! Each time you view a page, google views it as well so it knows what ads to place on the site. I have nothing againt that, that is exactly what I want. BUT....do any of you have any creative ideas how to stop my script on the pages loaded by google? Is there some type of variable or something to identify them? Anyone have any ideas!

    Thanks so much for the help!

    Matthew
     
  2. gay2jp

    gay2jp Private First Class

    Can you ignore (not count) any looks from google's IP address?
     
  3. msteinblock

    msteinblock Private E-2

    I had actually thought of that. :) What are the chances that it will be the same IP everytime?
     
  4. goldfish

    goldfish Lt. Sushi.DC

    It doesn't have the same IP every time due to load balancing. However, it does have the same user agent every time :D Use that to ignore entires made by google. The indexing spider comes up with the browser "Googlebot" in the UA string. Easy way to work it out though, just record the UA's and simply copy the entry in the DB and find the common factor, so you can use an if or somthing to prevent it being added to the DB.
     
  5. msteinblock

    msteinblock Private E-2

    I used the $_SERVER['HTTP_USER_AGENT'] to determine what the "browser" was, which returned "Mediapartners-Google/2.1". I figured that may change as well, so I used eregi to pull out anything that said "google", which should not change no matter what version. I also duplicated that to reject msn logs as well. Thanks for the idea. It seems to be working great!
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds