Hosting behind a caching reverse proxy like Varnish can cause the captured IP address to be cached, giving false Tor node reports to Analytics.  This latest update to System - Google Tag Manager brings an alternative tracking method for users behind caching reverse proxy.

To get that sweet Server-Timing header with the visitor’s IP address flowing into your Google Tag Manager plugin, you need to set it up on your web server first. The Joomla plugin will grab it once it’s there—no sweat. Since you’re using Nginx, here’s how to make it happen.

Which Server Again?

This particular configuration is more complicated than most users will have.  If you don't know what any of this means, this configuration isn't relevant to you.  For those of you who do know what a caching reverse proxy is, you'll know why this configuration is necessary.

The Server-Timing header isn't necessary on your actual host, but something you'll want to implement on your load balancer.  As you'll see below, the configurations for both Nginx and Apache2 are both very simple.

Configure Nginx to Send the Header

Nginx makes this a breeze by letting you inject the Server-Timing header with the visitor’s IP address ($remote_addr) for every request. Here’s what to do:

Open Your Nginx Site Config:

Find your site’s configuration file, usually in /etc/nginx/sites-available/your-site.conf (or similar, depending on your setup).
Open it in your favorite editor (e.g., nano or vim).

Add the Header Directive:

add_header Server-Timing "remote_addr;desc=\"$remote_addr\"";

Test Your Config:

Test your config: nginx -t
If it’s good, reload: service nginx reload or nginx -s reload

Apache2 Configuration Isn't Much Different

If you're still running Apache2, follow these steps.

Apache site-level config or vhost

/etc/apache2/sites-available/example.conf or inside a <VirtualHost> block

Add the Header Directive:

SetEnvIf Remote_Addr ".*" REAL_IP=$0
Header always set Server-Timing "remote_addr;desc=\"%{REAL_IP}e\""

If You Are Using Varnish

You may not be able to inject the header before Varnish takes over the connection, so use Varnish to inject the header!

Inside your VCL:

Somewhere inside sub vcl_vdeliver {

set resp.http.Server-Timing = "remote_addr;desc=" + req.http.X-Real-IP;

Now Every Response Carries The Header

Server-Timing: remote_addr;desc="203.0.113.5"

How This Differs From the Default Method

The default method relies on the server to identify a Tor node, and place a specific JavaScript option in place for the front-end event script to find.  This is the easiest to implement, but places additional burden on your server.  Not much,  just a single array lookup.

The Proxy method is easy on the server, but requires additional bandwidth (to send the Tor node list) and server configuration to allow the client to perform its own test.  There are trade-offs for each method.  I wrote this new method because my own configuration is affected by the reverse proxy caching.  If it affects me, it surely affects someone else.  I like my solutions to be permanent and portable, which made this an ideal candidate for an upgrade to my GTAG plugin.

You're welcome.

Why is this software free?

I’m ditching the freemium game and giving this software to the Joomla crowd for free. It’s a nod to “Jumla”—Swahili for “all together”—because fragmentation sucks, and I’d rather focus on innovation and paid gigs. Use it, build with it, and if you need custom work, I’m super into that.

What's The Catch?

There isn’t one! I’m all about building tools that empower the Joomla community and spark creativity. This software’s free because I’d rather see it in your hands - fueling awesome projects. If you really feel like paying something, I’d appreciate a review in the Joomla Extension Directory—your feedback means a lot!