Google Analytics IP Address Tracking Script with PHP

Google Analytics is by far the most widely used web analytics software, free or enterprise level, but it has several downsides, including lack of IP address tracking. You are able to drill down to the Service Provider names but that does not provide enough detailed data, especially if there are several users that use the same ISP but are in no other way related to each other, which can be a problem when analyzing traffic data.

Google Analytics obviously uses IP address tracking in their system but they choose not to reveal that data to its users for privacy reasons. This really does not make much sense to me since nearly every other web analytics tool allows you to track IP addresses. But luckily there may be a way around that by adding custom tracking variables with PHP (although it may be against Google Analytics TOS, which I am not really sure what will happen if you break the TOS).

So, here is how you can do track IP addresses in Google Analytics with this PHP and JavaScript script:

“javascript:__utmSetVar(‘php echo IP address function’)”>

Now you will be able to look up IP addresses in the User Defined field of the Visitors tab in the Google Analytics dashboard.

PHP Contact Form Script Generator

I am thinking about creating a PHP contact form script generator since pretty much every single website I work on uses a contact form in one way or another. The majority of the time I simply just copy and paste the same basic contact form template over and over, but it gets messy when older versions of the form tend to break or get flooded with spam, so I constantly have to add spam validation measures to various websites.  Most of the free contact form scripts available on the web are extremely outdated and don’t use any kind of validation to prevent the spambots from flooding them with gibberish. Yes, I know there are a ton of “new” contact form scripts out there, but it just seems that none of them are exactly what I want. Some of them are just way too slow because they include way too many validation measures which ends up taking 10 seconds for the form to be processed, which of course is very bad website usability and negatively affects conversion rates.

So my PHP contact form script will be very lightweight and thus very fast. It will be simple to set up and customize. It will also have a nice design feature so it doesn’t look like a boring old form or just look plain ugly. It will automatically include some PHP code on the script processing side to filter out spam on the backend along with maybe some JavaScript and clever CSS code to prevent spam on the frontend. Oh, and there definitely will not be any kind of CAPTCHA or other “are you a human?” related question, that’s for sure! I cannot stand those!

Anyways, stay tuned as I work on building the “perfect” PHP Contact From Script Generator, which will probably take months before I forget about it altogether. :P

Screening Anchor Text in Contact Form Spam

I wrote a blog post last year about “How to Stop Contact Form Spam” and it seems to do the job to weed out the bots from hitting your form processing script automatically and submitting a bunch of spam. However, it looks like one of my websites is getting hit manually by a person or script – they are filling out all of the required fields with a valid-formatted email address and actually clicking the submit button to access the confirmation page. However, they are flooding the “Message” textarea box with thousands of pharmaceutical words, some of which are hyperlinked to their spam sites. The most logical way I can think of to combat these spammers is to screen out all submissions that have keywords in the anchor text of any links submitted. I don’t want to disallow URLs completely, but only those that contain custom anchor text. I’ve Googled variations of “anchor text contact form spam” but have come up with nothing.

So I will need to figure out how to do this myself, either with PHP and/or JavaScript. I DON’T WANT TO USE A CAPTCHA or any other question to check if it’s a human or not, because there’s a very good chance that it is a human! If anybody has any suggestions, please leave them in the comments!!

Execute PHP in WordPress Widget Sidebar

In case you need to execute PHP in the widget sidebar of WordPress, check out this site:

http://www.hongkiat.com/blog/execute-php-in-wordpress-post-page-and-widget-sidebar/