I needed a way to turn off Google Ads while I was developing a site of mine so it didn’t skew my statistics. With WordPress it was pretty easy, I just checked if user level was equal to 10 and then not show the ads. But, I needed something different for site that I was using Etomite for.
First, an apology. If you are coming to this page because you found it in your logs, it means that I forgot to change my user-agent back, or I browsed to your site while I was working on my site.
My first thought was to not show the ads if my IP address was the remote host. But, I’m on a cable modem in Houston, so that IP address could potentially be a lot of people.
But, if I could get a custom string in to my browser’s user agent I could check for that string and show or hide the ads depending on what’s found. Now all I need is an easy way to change the user agent, and more importantly an easy way to change it back.
I found an extension for FireFox called ‘User Agent Switcher‘ that fits the bill perfectly. It adds a menu choice that allows me to change from my default user agent to anything I choose.
In the settings I made a user agent called ‘RCN Development’ and now have PHP code that checks the UA for that string and outputs or hides based on what it sees. Quick, easy, and it works.