Stop diluting your Google Adsense and Analytics when browsing your own sNews site
filed under: sNews CMS / Hacks & Mods
OK, we all know that clicking your own Adsense ads is bad news, so why risk it? You can prevent accidentally clicking them on your sNews installation easy enough... by simply not showing them when you're logged in, you don't need to see your own ads anyways, or run up your page impression count.
You can do this same little trick to hide yourself from Google Analytics, and save yourself having to set up filters for your own IPs.
In your index.php, where you want to display your Google code (or any code that you want only the browsing public to see, and not yourself), simply wrap it like this;
<?php
if(!_ADMIN) { //not logged in so let's display the code
?>
<script type="text/javascript"><!--
google_ad_client = "pub-000000000000000000";
/* 468x60, created 12/15/08 */
google_ad_slot = "00000000000";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<?php
} // all done
?>
If you want to use PHP and your IP address to always avoid showing you Adsense or keep you out of Analytics stats, you can use the following instead, be sure to replace the 111.111.111.111 with your own IP address;
<?php
if($_SERVER['REMOTE_ADDR'] != '111.111.111.111') { //not you, so let's display the code
?>
your google code here...
<?php
} // all done
?>
That basically says "show this to everyone except those logged in as an Admin". This way you won't dilute your Google Analytics or accidentally click your own Adsense ads.
Comments
No comments posted yet, why not be the first?
Categories
Recent Entries
Recent Comments
- Dede (I checked it today in a shop. GT2 had some troubles with six ...)
- Matt (Bintang, You need to re-direct the url, try ...)
- jesth (Ohh.. why didn't I think of that, thanks alot.)
- Matt (Dede, I don't have Gran Turismo 2, any of the 2nd+ generation ...)
- Matt (Jesth, Just change the if condition, instead of looking for ...)
- jesth (Hi (again) Was wondering, is it possible to make it ...)
- Bintang Sembilan (Matt, thanks for your modd. I have apply it to my ...)
- Dede (Hello there. Can you check something for me? I want to buy ...)
- Matt (I think it's a driver issue Terrence, or it was a driver issue. ...)
Popular Entries
- Light-weight related articles mod for sNews 1.7 (4.5/5)
- Image / math hybrid captcha version 2, vastly improved (4.42/5)
- 1024x600 netbook wallpapers of Evangeline Lilly (4.4/5)
- Compact archives for sNews 1.7 (4.4/5)
- sNews Ajax Polls mod now available (4.38/5)
- Pretty date and comments bars in sNews CMS (4.35/5)
- Page caching mod for sNews 1.7 (4.33/5)
- Gravatar mod for sNews 1.7 (4.29/5)
- An improved tag cloud for sNews 1.7 (4.29/5)