I'm writing a PHP site, and am using google analytics to track site activity.
I've written a function that's going to echo the tracking code, that can be included in the common site footer.
The thing is, I don't want it to track hits from our office (I've had mixed results with Google Analytics' IP filter before so have chosen to hard code it this time), and hits to admin pages.
So Pseudo code would be,
IF (PHP_self does contain admin) OR (IP address is not office) echo tracking code
The actual way I've written this is:
if (!( (substr($_SERVER['PHP_SELF'], 0, 7) == '/admin/') || ($_SERVER['REMOTE_ADDR'] == 'xxx.xxx.xxx.xxx') )) {
Is the best way to do it?
I tried the following but it didn't work:
if ( (substr($_SERVER['PHP_SELF'], 0, 7) != '/admin/') || ($_SERVER['REMOTE_ADDR'] != 'xxx.xxx.xxx.xxx') ) {