関連記事:WordPressのアクセス解析(カウンター)プラグインCounterize IIを導入CommentsAdd Star
カウンターを表示できるプラグインCounterize IIを先日入れたのだが、先日の手順ではユニークな数で表示してくれない。
つまり、1ユーザが2ページ遷移したらカウントが+2されてしまう訳だ。
なんか騙しカウンターみたいで嫌だなぁ~と思っていたので、暇な今、対処してしまおうと思う。
「昨日」のカウントを取るコードを書くことも出来るそうなのだが、自分のブログには不要なのでそれはカットする。
手順
- wp-content/plugins/counterizeii/browsniff.phpの末尾(?>の前)に以下のfunctionを追加
- サイドバー(sideber.php)の適切な箇所に以下を追記。または変更。要はカウンターを表示させたい場所。
- WordPressのアクセス解析(カウンター)プラグインCounterize IIを導入
- WordPress -My Category Orderプラグイン導入
- WordPress -最新のエントリーに投稿日付を表示する
- WordPress ページナビを表示するWP-PageNaviプラグイン
- eclipse -PHPプラグイン(PDT)のインストール
function counterize_getuniquehitstotal()
{
$sql = 'SELECT count(DISTINCT ip,date(timestamp)) FROM ' . counterize_logTable();
$wpdb =& $GLOBALS['wpdb'];
return $wpdb->get_var($sql);
}
<?php echo number_format(counterize_getuniquehitstoday()); ?> <!-- 今日のユニークなカウント -->
<?php echo number_format(counterize_getuniquehitstotal()); ?> <!-- トータルのユニークなカウント -->
<?php echo counterize_get_online_users(); ?> <!-- 現在の訪問者数 -->
参考:Counterize II でWordPressにカウンタを表示する
関連するかもしれない記事
他のブログも読む



One Response
Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.
Continuing the Discussion