# Check your visitors in the browser (iplogs.com)

A plain IP lookup sees an address. This check runs in the visitor's browser and sees the connection: the handshake, the DNS resolver, IPv4 against IPv6, the time zone. Add one script tag and read the answer in JavaScript. Free, no key, no sign-up.

```html
<script src="https://iplogs.com/iplogs.js" data-callback="onIplogs" async></script>
```

`onIplogs(result, error)` is called once. Or call `iplogs.check()`, which returns a Promise of the result.

## HTML & site builders

index.html. Paste before </body>: Webflow, Wix, Squarespace, Ghost, any page.

```html
<script src="https://iplogs.com/iplogs.js" async></script>
<script>
  window.addEventListener("load", function () {
    if (!window.iplogs) return; // blocked: let the visitor through
    iplogs.check().then(function (result) {
      if (result.is_vpn || result.is_proxy || result.is_tor) {
        // show a notice, ask for another step, or tag it in your analytics
      }
    }, function () { /* timed out or failed: let the visitor through */ });
  });
</script>
```

## React

useIplogs.ts. React 18 or newer, TypeScript (see Types).

```tsx
import { useEffect, useState } from "react";

import type { IplogsResult } from "./iplogs";

function loadScript(): Promise<void> {
  if (window.iplogs) return Promise.resolve();
  return new Promise((resolve, reject) => {
    const tag = document.createElement("script");
    tag.src = "https://iplogs.com/iplogs.js";
    tag.async = true;
    tag.onload = () => resolve();
    tag.onerror = () => reject(new Error("iplogs script blocked"));
    document.head.appendChild(tag);
  });
}

export function useIplogs() {
  const [result, setResult] = useState<IplogsResult | null>(null);
  useEffect(() => {
    let live = true;
    loadScript()
      .then(() => window.iplogs!.check())
      .then((r) => live && setResult(r))
      .catch(() => {}); // blocked or timed out: let the visitor through
    return () => {
      live = false;
    };
  }, []);
  const masked = !!result && (result.is_vpn || result.is_proxy || result.is_tor);
  return { result, masked };
}

// function Banner() {
//   const { masked } = useIplogs();
//   return masked ? <p>You appear to be on a VPN or proxy. Some features may be limited.</p> : null;
// }
```

## Next.js

VpnNotice.tsx. App Router, next/script, TypeScript (see Types).

```tsx
"use client";

import Script from "next/script";
import { useState } from "react";

import type { IplogsResult } from "./iplogs";

export function VpnNotice() {
  const [masked, setMasked] = useState(false);
  return (
    <>
      <Script
        src="https://iplogs.com/iplogs.js"
        strategy="afterInteractive"
        onReady={() => {
          window.iplogs?.check().then(
            (r: IplogsResult) => setMasked(r.is_vpn || r.is_proxy || r.is_tor),
            () => {} // timed out or failed: let the visitor through
          );
        }}
      />
      {masked && <p>You appear to be on a VPN or proxy. Some features may be limited.</p>}
    </>
  );
}
```

## Vue 3

useIplogs.ts. Composition API, TypeScript (see Types).

```ts
import { computed, onMounted, ref } from "vue";

import type { IplogsResult } from "./iplogs";

function loadScript(): Promise<void> {
  if (window.iplogs) return Promise.resolve();
  return new Promise((resolve, reject) => {
    const tag = document.createElement("script");
    tag.src = "https://iplogs.com/iplogs.js";
    tag.async = true;
    tag.onload = () => resolve();
    tag.onerror = () => reject(new Error("iplogs script blocked"));
    document.head.appendChild(tag);
  });
}

export function useIplogs() {
  const result = ref<IplogsResult | null>(null);
  onMounted(async () => {
    try {
      await loadScript();
      result.value = await window.iplogs!.check();
    } catch {
      // blocked or timed out: let the visitor through
    }
  });
  const masked = computed(() => !!result.value && (result.value.is_vpn || result.value.is_proxy || result.value.is_tor));
  return { result, masked };
}

// <p v-if="masked">You appear to be on a VPN or proxy. Some features may be limited.</p>
```

## WordPress

functions.php. Child theme or a code-snippets plugin.

```php
<?php
add_action('wp_footer', function () { ?>
<script src="https://iplogs.com/iplogs.js" async></script>
<script>
  window.addEventListener("load", function () {
    if (!window.iplogs) return; // blocked: let the visitor through
    iplogs.check().then(function (result) {
      if (result.is_vpn || result.is_proxy || result.is_tor) {
        document.documentElement.classList.add('visitor-masked'); // style it with CSS
      }
    }, function () { /* timed out or failed: let the visitor through */ });
  });
</script>
<?php });
```

## Shopify

layout/theme.liquid. Just before </body>. Storefront pages only: theme.liquid does not apply to checkout.

```liquid
<script src="https://iplogs.com/iplogs.js" async></script>
<script>
  window.addEventListener("load", function () {
    if (!window.iplogs) return; // blocked: let the visitor through
    iplogs.check().then(function (result) {
      if (result.is_vpn || result.is_proxy || result.is_tor) {
        document.documentElement.classList.add('visitor-masked'); // style it with CSS
      }
    }, function () { /* timed out or failed: let the visitor through */ });
  });
</script>
```

## Google Tag Manager

Custom HTML tag. Trigger: All Pages. Read iplogs_result in a Custom Event trigger.

```html
<script>
  (function () {
    var tag = document.createElement("script");
    tag.src = "https://iplogs.com/iplogs.js";
    tag.async = true;
    tag.onload = function () {
      window.iplogs.check().then(function (result) {
        window.dataLayer = window.dataLayer || [];
        window.dataLayer.push({
          event: "iplogs_result",
          iplogs_verdict: result.verdict,
          iplogs_masked: result.is_vpn || result.is_proxy || result.is_tor
        });
      }, function () { /* timed out or failed: send nothing */ });
    };
    document.head.appendChild(tag);
  })();
</script>
```

## No script from us

index.html. Nothing to load: you own every line that runs on your page.

```html
<script>
  (function () {
    var id = Array.from(crypto.getRandomValues(new Uint8Array(16)), function (b) {
      return ("0" + b.toString(16)).slice(-2);
    }).join("");
    window.addEventListener("message", function (e) {
      var m = e.data;
      if (e.origin !== "https://iplogs.com" || !m || m.source !== "iplogs" || m.id !== id) return;
      if (m.type === "result") {
        var result = m.result;
        if (result.is_vpn || result.is_proxy || result.is_tor) {
          // show a notice, ask for another step, or tag it in your analytics
        }
      }
    });
    var frame = document.createElement("iframe");
    frame.src = "https://iplogs.com/embed?v=1&id=" + id;
    frame.setAttribute("sandbox", "allow-scripts allow-same-origin");
    frame.setAttribute("referrerpolicy", "no-referrer");
    frame.style.display = "none";
    document.body.appendChild(frame);
  })();
</script>
```

## Types

iplogs.d.ts. TypeScript projects.

```ts
export interface IplogsResult {
  ip: string;
  verdict: "clean" | "suspicious" | "vpn_likely" | "vpn_detected";
  score: number;
  is_vpn: boolean;
  is_proxy: boolean;
  is_tor: boolean;
  is_relay: boolean;
  is_hosting: boolean;
  proxy_type: string;
  vpn_provider: string;
  country_code: string;
  asn: string;
  org: string;
  mode: string;
  request_id: string;
  signals: { type: string; weight: number }[];
}

declare global {
  interface Window {
    iplogs?: {
      version: string;
      check(options?: { mode?: "fast"; fresh?: boolean; cacheMs?: number; timeout?: number }): Promise<IplogsResult>;
    };
  }
}
```

## The result

| Field | Meaning |
| --- | --- |
| verdict | clean, suspicious, vpn_likely or vpn_detected |
| score | 0 to 1 |
| is_vpn, is_proxy, is_tor | The three flags to act on |
| is_relay | iCloud Private Relay or Cloudflare WARP. Leave it out of a rule to let those visitors through |
| is_hosting | A datacenter or cloud address |
| proxy_type | residential, isp, public or datacenter when is_proxy is true, otherwise empty |
| vpn_provider | The VPN brand when one is known, otherwise empty |
| ip, country_code, asn, org | The address and the network behind it |
| mode | fast when the answer came from memory without live probing, otherwise empty |
| request_id | The id of this check |
| signals | The type and weight of each signal that fired, without detail text |

## Before you rely on it

- It is a signal, not proof. The check runs in the visitor's browser and page JavaScript can be edited. Use it to show a notice, add a step or tag analytics. To enforce a decision, call the API from your server with the visitor's IP (https://iplogs.com/sdks).
- Fail open. If the script is blocked, the visitor is offline or the check times out (25 seconds), check() rejects. Let the visitor through.
- Content-Security-Policy: allow script-src https://iplogs.com and frame-src https://iplogs.com. The check's own requests happen inside our frame.
- A full check probes the address and takes about 3 seconds. Answers are reused for 10 minutes per tab. check({ mode: "fast" }) answers at once from memory, without live probing.
- The check sends us the visitor's IP address, time zone and language, plus technical details of the connection. No cookies are set. https://iplogs.com/privacy says how long logs are kept.

## Pin a version

```html
<script src="https://iplogs.com/iplogs/1.0.0.js"
        integrity="sha384-FBkrH4hznwNpOahOChEPs68P4K9mvVj9k1mDFiJGpLj8il9N75mOGkYSe/LaLku/"
        crossorigin="anonymous" async></script>
```

## Prompt for an AI coding assistant

```text
Add an iplogs.com check of the visitor's own connection to this project.

What it does: tells us whether the visitor is on a VPN, proxy, Tor or datacenter connection. It runs in the browser and sees more than an IP lookup does (the connection handshake, the DNS resolver, IPv4 against IPv6, time zone).

How to wire it up:
1. Load https://iplogs.com/iplogs.js with an async script tag. It adds window.iplogs.check(), which returns a Promise of the result. No key, no package.
2. The result has: verdict ("clean", "suspicious", "vpn_likely" or "vpn_detected"), score (0 to 1), is_vpn, is_proxy, is_tor, is_relay, is_hosting, ip, country_code, asn, org, request_id.
3. Treat is_vpn || is_proxy || is_tor as "masked". Leave is_relay (iCloud Private Relay, Cloudflare WARP) out unless I say otherwise.
4. Fail open: if check() rejects (script blocked, offline, 25 second timeout), let the visitor through.
5. Call it once per page load. Answers are reused for 10 minutes in sessionStorage. check({ mode: "fast" }) answers at once from memory, without live probing.
6. Do not block payments, sign-ups or logins on this alone: the result is produced in the visitor's browser and can be edited. Use it to show a notice, add a step, or tag analytics. To enforce a decision, call POST https://iplogs.com/v1/check from the server with {"ip": "<visitor ip>"} (see https://iplogs.com/sdks).
7. If the site sets a Content-Security-Policy, allow script-src https://iplogs.com and frame-src https://iplogs.com.

Use my project's framework, language and code style. If it is unclear where the decision should be made or what should happen to a masked visitor, ask me before writing code.
```
