GoAdmio

googletop

Report IPs that arrive from Google Ads clicks, list repeat visitors, and build a block list

On this page: Overview · Quick start · Syntax · Options · Output · Examples · Troubleshooting · Details · See also


Overview

When someone clicks a Google ad, Google Ads (with auto-tagging on) adds a gad_campaignid parameter to the landing-page URL. /go/googletop searches the web server's access logs for requests that contain it, counts the visits per IP address, and shows who is clicking your ads.

Repeated clicks from the same IP are often bots or click fraud, so the command can also list the repeat offenders and prepare a block list.

It has three modes:

Mode Command What it does
Report /go/googletop Table of IPs with visits, country, city, and company.
Max /go/googletop max [n] Plain list of IPs with at least n visits (default 2).
Block /go/googletop block Builds a block list and prints it.

[!IMPORTANT] block mode does not block anything itself. It writes and prints a list. To apply it, use a command such as block or waf.


Quick start

# Who is clicking my ads?
/go/googletop

# IPs with 2 or more ad-click visits
/go/googletop max

Syntax

/go/googletop
/go/googletop max [n]
/go/googletop block

Any other first argument (for example a domain name) does not filter by domain. It only prints the final IPs: count.


Options

Argument Required Default Notes
max No — Lists only IPs with at least n visits.
n No 2 Minimum visits for max. A missing, 0, or non-numeric value becomes 2.
block No — Builds the block list. Uses a fixed minimum of 2 visits for the IP list.

With no arguments, the command runs in report mode.


Output

Report mode

IP            VISITS  COUNTRY  CITY      COMPANY
203.0.113.10  42      US       Ashburn   Example Hosting Inc
198.51.100.7  9       DE       Frankfurt Example Cloud GmbH
------------------------------------------------
IPs: 2
------------------------------------------------

The server's own IPv4, IPv6, and 127.0.0.1 are left out.

Max mode

203.0.113.10
198.51.100.7
------------------------------------------------
IPs: 2
------------------------------------------------

The footer is printed in this mode too. Remove it if you pass the list to another tool.

Block mode

Block mode prints, in order:

  1. A fixed set of large ranges: 52.0.0.0/11, 54.0.0.0/11, 34.0.0.0/11, 35.0.0.0/11, 20.0.0.0/11, 23.0.0.0/11, 159.203.0.0/16, 89.0.0.0/8, and 146.70.0.0/16.
  2. Ranges that contain two or more of the IPs found, such as 203.0.113.*.
  3. The output of /go/googletop max 2 (the IPs with 2 or more visits, with the footer).

The fixed ranges are only printed. They are not added to block.db.

Other messages

Message Meaning
Log Seconds: <n> between dashed lines The access log hasn't been written to for more than 60 seconds, so the data may be stale. See Troubleshooting.
File /var/log/apache2/access.log not found. No access log was found (Debian/Ubuntu). The command stops.

Report and max modes end with exit status 0. Block mode always exits with 1.

Every run is logged to /var/log/go/googletop.log with a timestamp and the arguments used.


Examples

# Full report
/go/googletop
# IPs with at least 5 ad-click visits
/go/googletop max 5
# Build the block list
/go/googletop block
# Block one reported IP
/go/block 203.0.113.10

Troubleshooting

Symptom Likely cause Fix
IPs: 0 and an empty table No requests contain gad_campaignid, or the log format differs from the expected one. Check that Google Ads auto-tagging is on and that the logs use GoAdmio's format. See Details.
Visit counts look wrong for some IPs When the server's own IP or 127.0.0.1 appears in the results, the counts for the rows after it are shifted. Ignore the counts around the server's IP, or check the raw log with zgrep gad_campaignid.
The report is very slow Report mode runs a WHOIS lookup for every IP (up to 5000). Use max mode, which skips the lookups.
Country or city is empty WHOIS didn't return the field. Run the report in a terminal, where the command uses its own country and city lookup.
Log Seconds shows a huge number, such as 1795000000 The check only reads the log's modified time on Nginx with AlmaLinux, Rocky, CentOS, Red Hat, or Fedora. On other systems it is empty and the banner is wrong. Ignore the banner.
Log Seconds shows a small number such as 120 The log hasn't been written to for that many seconds. Check that the web server is running and logging.
File ... not found. The access log isn't in the usual place. Check the log path for your web server.
The command waits and doesn't return The OS isn't supported, so no log path is set and zgrep waits for input. Press Ctrl+C. Supported systems are listed in Details.
Block mode didn't block anything It only builds and prints a list. Apply the list with block or waf.
A domain argument has no effect The first argument is a mode, not a domain. Run the command without a domain.

Details

How it works

flowchart TD
    A["/go/googletop"] --> B["Pick the access log files"]
    B --> C["zgrep: lines containing gad_campaignid"]
    C --> D["Extract the client IP of each line"]
    D --> E["Count visits per IP (top 5000)"]
    E --> F{"Mode?"}
    F -- "none" --> G["WHOIS each IP and print the table"]
    F -- "max" --> H["Print IPs with n or more visits"]
    F -- "block" --> I["Build block.db, print ranges, then run max 2"]

The command searches all access log files that match the pattern, including rotated and compressed ones, so the report covers as far back as your log rotation keeps data.

Log format

The IP is read from GoAdmio's pipe-delimited (|) access log. Field 4 is used when it isn't -, otherwise field 3. Field 11 must contain gad_campaignid.

Block mode

  1. Deletes /usr/local/goadmio/tmp/block.db.
  2. Adds every IP found to block.db.
  3. Prints the fixed list of ranges.
  4. Turns IPv4 addresses in block.db into a.b.c.* and shortens IPv6 addresses to a /64-style prefix.
  5. Prints the ranges that appear more than once, meaning two or more offending IPs share them.
  6. Runs /go/googletop max 2.

[!WARNING] The fixed list includes 89.0.0.0/8, about 16 million addresses, plus large cloud and hosting ranges. Blocking them can lock out real visitors. Review the list before you apply it.

Supported systems

OS Web server Log files searched
AlmaLinux, Rocky, CentOS, Red Hat, Fedora Apache /var/log/httpd/access*
AlmaLinux, Rocky, CentOS, Red Hat, Fedora Nginx /var/log/nginx/access.*
Debian, Ubuntu Apache /var/log/apache2/access*, or other_vhosts_access* if there is no access.log
Debian, Ubuntu Nginx /var/log/nginx/access*, or other_vhosts_access* if there is no access.log

Files and requirements

Item Used for
/usr/local/goadmio/tmp/google-ads.log The matching log lines. Overwritten on every run.
/usr/local/goadmio/tmp/googletop.db The extracted IPs. Overwritten on every run.
/usr/local/goadmio/tmp/block.db The block list built in block mode.
/var/log/go/googletop.log The command log.
curl Finding the server's own IPv4 and IPv6 so they can be left out.
zgrep, awk, sort, column Reading and formatting the data.
WHOIS, COMPANY, COUNTRY, CITY Lookups in report mode. These are not defined in the script, so they must be available on the server.

Dormant code

The script reads the admin email, mobile number, and WhatsApp settings from config.db, and it contains code to send an email and a WhatsApp alert. The alert counter is never increased, so no alert is ever sent.


See also

Command Description
block Block an IP address on a GoAdmio server
unblock Unblock an IP address on a GoAdmio server
waf Block IPs via Cloudflare WAF
iptop Track the most visited IP addresses on a server
posttop Track and check IPs making POST requests
ddos Track and block DDoS attack IPs in GoAdmio
google Add Google verification and Workspace DNS records via Cloudflare