Analytics and product tools

Check IP addresses, domain authority and links in Google Analytics 4

Take the addresses behind your server-side sessions, add country, network owner and risk flags, and keep hosting and Tor traffic out of conversion analysis.

Why the data matters in Google Analytics 4

Analytics reports count every session as a person. Traffic from data centers and Tor exits inflates sessions and drags down conversion rates, so a campaign that looks weak may only be diluted by machines, and teams make budget calls on the diluted number.

What LookValid checks

LookValid checks for Google Analytics 4
ProductWhat it does hereCredits
IP IntelligenceReturns country, region, city, time zone, network owner and flags for hosting ranges and Tor exits from open data. Location is approximate and is not a person's address.1 credit per lookup
Domain AuthorityScores a referring domain from open link-graph rankings so you can sort referral sources by weight. It is not another vendor's authority score.10 credits per domain found in the rank data (an unranked domain is free)
Link Safety CheckChecks the domain of a referral or landing URL against a public list of reported malicious domains.1 credit per URL checked (a check that cannot run is free)

Connect it in four steps

  1. Create a LookValid account and an API key from the dashboard, which a person does once.
  2. Set the key as the LOOKVALID_API_KEY environment variable in the job that runs the script, not in the script file or the repository that holds it.
  3. Call the function for each distinct address in the export rather than each row; a None return means found was false, and an exception carries the error code and fix.
  4. Save the country, network owner, hosting, Tor and risk values in a table keyed by address, then join it, on a session key you keep in both places, to the daily events table that BigQuery Export writes for your property.

A script that reads your own server logs for the addresses behind sessions, checks each one, and saves the result in a table you join to the events_YYYYMMDD tables from Analytics BigQuery Export. The call is POST https://YOUR_API_HOST/v1/ip and costs 1 credit per lookup.

check_session_ip.py
import json
import os
import urllib.error
import urllib.request
​
API_URL = "https://YOUR_API_HOST/v1/ip"
​
​
def check_session_ip(value):
    request = urllib.request.Request(
        API_URL,
        data=json.dumps({
            "ip": value,
        }).encode(),
        headers={
            "Authorization": "Bearer " + os.environ["LOOKVALID_API_KEY"],
            "Content-Type": "application/json",
        },
        method="POST",
    )
    try:
        with urllib.request.urlopen(request, timeout=30) as response:
            result = json.load(response)
    except urllib.error.HTTPError as error:
        failure = json.load(error)["error"]
        raise RuntimeError(failure["code"] + ": " + failure["fix"])
    if not result["found"]:
        return None
    return {
        "ip_country": result.get("data", {}).get("country"),
        "network_owner": result.get("data", {}).get("asn_org"),
        "is_hosting": result.get("data", {}).get("is_hosting"),
        "is_tor": result.get("data", {}).get("is_tor"),
        "risk_score": result.get("data", {}).get("risk_score"),
    }
Where each response field goes in Google Analytics 4
Response fieldGoes into
data.countryip_country
data.asn_orgnetwork_owner
data.is_hostingis_hosting
data.is_toris_tor
data.risk_scorerisk_score

The recipe returns nothing when the lookup finds nothing, which costs no credits for this product, and stops with the error code and fix on a failed request.

Without code

Without code, an automation platform's generic HTTP request step can read new rows from a log table or sheet, send each address to LookValid and write the answer back beside it. No dedicated LookValid app is used, and the table can be queried next to your exported events.

REST and MCPOne shared credit balance

Questions

What does it cost in credits?

The pricing page lists the credits for the IP product. Check each distinct address once and reuse the result to keep the count low.

What does the IP check not do?

It does not identify a person and its location is approximate. A hosting flag means the address belongs to a hosting range, not that the visitor is a bot.

Where does the key go?

In an environment variable of the job that runs the script.

Sources

LookValid is run by Meralume Labs. It is not connected to, endorsed by or a partner of any company or product named on this page, and every product name belongs to its owner.

LookValid bills every lookup in credits from one shared balance, so the same key works for each check above.

See IP Intelligence