WP Statistics can use visitor IP addresses to tie together hits from a single visitor across a session (even if it doesn’t actually store the IP address after that).
It can get the visitor’s IP address from any HTTP header accessible to PHP, eg: REMOTE_ADDR, HTTP_X_FORWARDED_FOR, HTTP_X_REAL_IP.
We’re running the staging site inside a docker container and behind a load-balancer. Our current setup doesn’t expose the user’s IP address neatly in any of the headers – HTTP_X_REAL_IP is the address of the load balancer, and HTTP_X_FORWARDED_FOR is a comma-separated list of IPs.
If we want to get Visitor data working in WP Statistics, we should either:
Fix HTTP_X_REAL_IP so that it returns the user’s IP.
Define our own wp_statistics_sanitize_user_ip filter, in the WordPress theme, which extracts the user’s IP address out of the HTTP_X_FORWARDED_FOR header. Example here.
No huge rush on this – we can still track individual page views ("Hits"). Combining them into sessions was only a nice-to-have, given the limitations around cookie-less tracking.
WP Statistics can use visitor IP addresses to tie together hits from a single visitor across a session (even if it doesn’t actually store the IP address after that).
It can get the visitor’s IP address from any HTTP header accessible to PHP, eg:
REMOTE_ADDR
,HTTP_X_FORWARDED_FOR
,HTTP_X_REAL_IP
.We’re running the staging site inside a docker container and behind a load-balancer. Our current setup doesn’t expose the user’s IP address neatly in any of the headers –
HTTP_X_REAL_IP
is the address of the load balancer, andHTTP_X_FORWARDED_FOR
is a comma-separated list of IPs.If we want to get Visitor data working in WP Statistics, we should either:
Fix
HTTP_X_REAL_IP
so that it returns the user’s IP.Define our own
wp_statistics_sanitize_user_ip
filter, in the WordPress theme, which extracts the user’s IP address out of theHTTP_X_FORWARDED_FOR
header. Example here.No huge rush on this – we can still track individual page views ("Hits"). Combining them into sessions was only a nice-to-have, given the limitations around cookie-less tracking.