WordPress.org

Forums

adsense adtest user detection hack (3 posts)

  1. Jonathan Dingman
    Member
    Posted 9 years ago #

    Here's a small hack for those that want to be able to click on your own ads and not track those clicks/impressions.

    google_adtest = "<?php global $user_ID; get_currentuserinfo(); if (! $user_ID ) { echo 'off'; } else { echo 'on'; } ?>";

    what this will do for you is detect if you're logged in. If you're logged in, it will display adtest = "on"; which has been verified by Google AdSense to be a testing variable so you can click on your own ads and it won't count or be in violation of the TOS. It will also stop impression tracking for you. This is another good variable to use simply if you're testing a lot and you don't want to break your CTR or impressions.

    WARNING: Please note, YOU MUST BE LOGGED IN to use this. IF you're not logged in, it will seem like you're a visitor and track you accordingly.

    hope this hack helps someone.

    Thanks go to Skippy.

  2. EllenCBraun
    Member
    Posted 9 years ago #

    jdingman,

    Thanks, I think this will be very useful in testing my pages.

    Some questions: WHERE do I need to be logged in?

    Where EXACTLY would I place this code?

    This hack actually eliminates my page views from google's impression count, is that correct?

    Thanks!

  3. Jonathan Dingman
    Member
    Posted 9 years ago #

    You need to be logged into WordPress.

    you need to place this code inside the actual <script> of google adsense. While it is modifying the code, it's not altering the output at all -- it's simply saving the trouble from being counted while testing. I use this code quite often while developing and I don't want pageviews to effect my CTR.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags