Count visits of WordPress site

127 Views Asked by At

I want to show the total number of visitors on my WordPress site. So far, I'm using a plugin to count the post visitors. and I did iframe for one post in the footer of site (non-visible).

<iframe id="tvc" src="<?php bloginfo('url'); ?>/mvc/"  width="50" height="50"></iframe>

and finally I called the number of visitors from it by JavaScript.

var embedvc = document.getElementById('tvc');
embedvc.onload = function() {
var iframe = document.getElementById("tvc");
var elmnt = iframe.contentWindow.document.getElementsByClassName("post-18371")[0];
document.getElementById("total-visits").innerText = elmnt.innerText;
}

Is there a better way?

0

There are 0 best solutions below