How to block IP addresses with LiteAnalytics.com

Written 7 months ago

Do you want to block IP addresses in Lite Analytics? Here is how:

  1. Install WP Code plugin
  2. Create a “Universal snippet”. Make sure its Universal and not PHP.
  3. Run the snippet everywhere
  4. Insert the complete code snippet shown below
  5. Change xx.xx.xx.xx to the ip addresse(s) of the blocked ip addresses. If you only have one IP address, just use one array item. Single quotes are needed around ip addresses.
  6. Change bbbbbb in the script below to the default host provided by liteanalytics website

Code to use:

<?php
$user_ip = $_SERVER['REMOTE_ADDR'];
$blocked_ips = array('xx.xx.xx.xx', 'xx.xx.xx.xx');  // Replace with your list of blocked IP addresses
if (!in_array($user_ip, $blocked_ips)):
?>
 <script defer async data-host="bbbbbb" src="https://liteanalytics.com/lite.js"></script>
<?php
endif;
?>

If you only have one IP address to block, then replace line 3 above with this:

$blocked_ips = array('xx.xx.xx.xx');// Replace with your IP address

Leave a Reply

Your email address will not be published. Required fields are marked *