First-Party Analytics
Cookieless visitor measurement that survives Brave and content blockers, plus an optional Google Analytics 4 bridge.
Visitor measurement in ai4shops.com is cookieless by design. No cookie is set,
no value is written to localStorage for measurement purposes, and no raw IP
address is stored. Visitors are counted using a rotating salted hash computed on
our servers, which means there is nothing on the visitor's device to consent to,
read back, or delete.
How visitors are counted
Instead of a persistent identifier, each page view is attributed to a hash:
visitor_id = sha256(rotating_salt + ip_address + user_agent + site_id)
The salt is random, stored server-side only, and rotates every 7 days. When it rotates, the old salt is discarded, so hashes from an earlier period can never be linked to the current ones. The IP address is used only to compute the hash — it is never written to the database.
Two consequences worth knowing before you read your numbers:
- A visitor returning after the rotation counts as a new visitor. Unique-visitor figures are therefore accurate within a period and conservative across periods.
- The same person on the same site cannot be linked across two different shops:
site_idis part of the hash, so identifiers never correlate between customers.
Respecting opt-out signals
Requests carrying Sec-GPC: 1 (Global Privacy Control) or DNT: 1 are answered
normally but nothing is recorded. This is deliberate: a first-party endpoint
could technically ignore those headers, but a visitor who explicitly asks not to
be measured should not be measured.
Making measurement work in Brave and with content blockers
Content blockers reject requests by hostname, not by intent. A measurement
call from a shop's page to ai4shops.com is a third-party request, and a
meaningful share of real visitors — Brave users in particular — will never send
it. The fix is to serve the ingest endpoint from your own domain.
Step 1: proxy the endpoint on your domain
Pick any path on your own site. /_i is used in the examples below.
Apache
ProxyPass /_i https://ai4shops.com/api/insights
ProxyPassReverse /_i https://ai4shops.com/api/insights
ProxyPass /_i/interaction https://ai4shops.com/api/insights/interaction
ProxyPassReverse /_i/interaction https://ai4shops.com/api/insights/interactionnginx
location /_i {
proxy_pass https://ai4shops.com/api/insights;
proxy_set_header Host ai4shops.com;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}X-Forwarded-For matters. Without it every visitor looks like your web server,
so geography and visitor counts collapse into a single value. Apache's
mod_proxy adds the header automatically; nginx needs the line above.
Step 2: point the script at it
Add data-ingest-base to the embed script:
<script
src="https://ai4shops.com/api/chatbot/widget/loader?projectId=proj_your_id"
data-ingest-base="/_i"
></script>Only a site-relative path is accepted. An absolute URL or a protocol-relative
value like //example.com is ignored and the script falls back to the canonical
endpoints, so a third party cannot redirect your visitor measurement elsewhere.
Expect measured traffic to rise once this is in place — typically from roughly 70% of real visitors to 90–95%. It never reaches 100%: a visitor with JavaScript disabled cannot be measured at all.
Sending the data to Google Analytics 4
Measurement can be mirrored into GA4 through the Measurement Protocol, from
our servers. No gtag.js runs in the visitor's browser, so this path is not
affected by blockers either.
Set two environment variables:
GA4_MEASUREMENT_ID=G-XXXXXXXXXX
GA4_API_SECRET=your_measurement_protocol_secretThe API secret is created in GA4 under Admin → Data Streams → your stream → Measurement Protocol API secrets. When either variable is missing, the bridge stays inactive and nothing is sent.
Events are forwarded in batches by the hourly analytics flush, backdated to their real event time, which GA4 accepts for up to 72 hours.
Geography in GA4 will show your server, not your visitors. The Measurement Protocol attributes each request to the sending server's IP address and offers no override. Our own dashboard keeps the real visitor geography; in GA4 it is available as custom event parameters, which you can map to custom dimensions. Native GA4 geography would require a server-side Google Tag Manager container.
Because of that limitation — and because our own database holds richer data than the Measurement Protocol can carry — treat the ai4shops.com dashboard as the source of truth and GA4 as a mirror for teams that already live there.