Making WP Statistics work with page cache
-
Hi!
When enabling the “Use Cache plugin” option (resaving permalinks, and clearing the cache), WP Statistics adds the following code, which seems to be used to create the API endpoint to process the visit data:
<script>var WP_Statistics_http = new XMLHttpRequest();WP_Statistics_http.open('GET', 'https://domain.extk/wp-json/wp-statistics/v2/hit?_=xxx&_wpnonce=yyy&wp_statistics_hit_rest=yes&browser=Chrome&platform=Windows&version=10.0&referred=https://referer.ext/&ip=zzz.zzz.zzz.zzz&exclusion_match=yes&exclusion_reason=user role&ua=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36 Edg/88.0.705.74&track_all=1×tamp=1614082764¤t_page_type=home¤t_page_id=0&search_query&page_uri=/&user_id=3', true);WP_Statistics_http.setRequestHeader("Content-Type", "application/json;charset=UTF-8");WP_Statistics_http.send(null);</script>The issue with that, and since the code is not added dynamically after the page loads, the first visit will generate the IP address, and all following visits will reference the same IP, referrer, etc.
Any way to Ajaxify the process? Otherwise, it won’t work with page caching unless the cache is flushed for each visitor, which defies the purpose of using the page cache in the first place.
Thank you for your efforts!
The topic ‘Making WP Statistics work with page cache’ is closed to new replies.