Đăng ngày 4 Tháng mười hai, 2008 trong mục WP Tips-Tricks | 7,779 lượt xem

After reading the article “Exclude your own visits in Google Analytics for WordPress blogs” on JohnTP.com,
I think that is very useful trick to exclude your own visits in Google Analytics when you access your WordPress blogs, using the code bellow to do that:

<?php if (!$user_ID) { ?> your Google Analytics code here <?php } ?>

But the code is not pretty well for blogs with enabled user registration because using $user_ID variable will exclude all visitors who has already been a member. You know that we are going to exclude tracking for only the administrator whose username is "admin" and level is 10 so that we need to have a better condition to detect which type of currently logged in user. I have an improvement for the code here, place it to your footer.php :

1
2
3
4
<?php global $current_user; get_currentuserinfo();
if ($current_user->user_level != 10 && $current_user->user_login != 'admin') { ?>
your Google Analytics code here
<?php } ?>

This code is currently working well on my blog. I hope it will help you to exclude your own visits in Google Analytics exactly!

PS: Note that you can use any web statistics code you like (statcounter for example), not just for Google Analytics.

Đăng ký nhận bài viết qua email
digg delicious stumbleupon technorati Google live facebook Sphinn Mixx newsvine reddit yahoomyweb

0 phản hồi cho “WP Tip: Let Google Analytics exclude your own visits”

  1. Bài này vẫn chưa có comment. Sao bạn không là người đầu tiên nhỉ?

Viết comment

Chức năng lọc comment của blog đang được kích hoạt vì thế những comment có từ ngữ thô tục hoặc có chứa một số link sẽ bị coi là spam. Vui lòng đừng bấm nút “Gửi Comment” hai lần, comment của bạn sẽ hiển thị sau khi đã qua kiểm duyệt.
Off Auto TELEX VNI VIQR VIQR*