Integrations
Serve the Loogika script from your own domain
Some ad blockers stop requests to analytics domains. If the script and the events go through your own domain, fewer visits are lost. You need a proxy, one changed script tag and one switch in Site Settings.
Last updated .
How does it work?
The script sends events to the address it was loaded from. When you load it from yourdomain.com/stats/script.js, the events go to yourdomain.com/stats/ too. Your proxy passes both on to Loogika.
How do you set it up?
- Set up a proxy on your domain that forwards a path, such as
/stats/*, tohttps://app.loogika.com/api/*. - Make the proxy send the visitor's IP address in
X-Real-IPorX-Forwarded-For. - Change the script tag to load through the proxy.
- Turn on First-Party Proxy under Site Settings, General.
<script src="https://yourdomain.com/stats/script.js?siteId=YOUR_SITE_ID" defer></script>
A CDN worker, nginx or the rewrite feature of your framework can act as the proxy.
Why does the IP header matter?
Loogika uses the IP address to find the country, to tell visitors apart and to detect bots. It does not store the address unless you turn that on.
Without the header, every visit seems to come from your proxy. All visitors then count as one, and every location is the proxy's.
How do you check that it works?
Open your site and look at the Network tab. The script and the requests to /stats/track should go to your own domain and return status 200.
Then open the realtime view from two different networks, for example your office and your phone. You should see two visitors in two places.
Questions about the proxy
Should First-Party Proxy be on without a proxy?
No. With the switch on, Loogika trusts the IP headers in the request. Leave it off unless your own proxy sets them.