2013-05-16 6 views
3

Google은 내부 WordPress 사이트와 약 25 명의 사용자를 보유하고 있습니다. Google의 현재 Google Analytics 설정은 페이지를 몇 번 방문했는지 표시하지만 모두가 동일한 IP 주소에서 왔기 때문에 기본적으로 매우 부지런한 사람 한 명이라고 생각합니다.Wordpress에서 내부 사용자 추적

개인 사용자를 추적하기위한 전략이 있습니까?

(그들은 모두에 우리의 싱글 사인온의 기능으로 워드 프레스에 기록됩니다.)

+0

당신의 문제는 다른 곳에 있어야합니다. –

답변

9

당신은 현재 사용자의 사용자 이름을 제공하기 위해 JavaScript API에서 _setCustomVar 방법을 사용할 수 있습니다. 내 지식으로는 Wordpress 용 GA 플러그인을 지원하지 않으므로 추적 코드를 직접 테마에 넣거나 사용자 정의 플러그인을 작성해야합니다. 그런 다음 맞춤 변수가 Google 웹 로그 분석의 세그먼트로 표시됩니다. 현재 사용자를 얻으려면 wp_get_current_user API call을 사용할 수 있습니다.

추적 코드는 다음과 같이 보일 것입니다 :

<?php 
    if (is_user_logged_in()) { 
     $user = wp_get_current_user(); 
     $userName = $user->user_login; 
    } 
?> 
<script type="text/javascript"> 

    var _gaq = _gaq || []; 
    _gaq.push(['_setAccount', 'UA-XXXXX-Y']); 
<?php if (isset($userName)) : ?> 
    _gaq.push(['_setCustomVar', 1, 'Username', <?php echo(json_encode($userName)); ?>, 1]); 
<?php endif; ?> 
    _gaq.push(['_trackPageview']); 

    (function() { 
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; 
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; 
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); 
    })(); 
</script> 

을 범용 웹 로그 분석 버전의 경우 :

내가 로그인 한 트랙 사용자 활동 Stream라는 공동 집필
<?php 
    if (is_user_logged_in()) { 
     $user = wp_get_current_user(); 
     $userName = $user->user_login; 
    } 
?> 
<script> 
    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ 
    (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), 
    m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) 
    })(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); 

    ga('create', 'UA-XXXX-1', 'auto'); 
    <?php if (isset($userName)) : ?> 
     ga('set', 'userId', <?php echo(json_encode($userName)); ?>); // Set the user ID using signed-in user_id. 
    <?php endif; ?> 
    ga('send', 'pageview'); 
</script> 
5

. 기본적으로 WP 관리 영역에서 일어나는 모든 것에 대한 자세한 감사 추적이되도록 설계되었습니다.

또한 사용자, 컨텍스트, 작업 및 IP 주소별로 활동을 구성하므로 나중에 쉽게 필터링/검색 할 수 있습니다.

더 많은 정보 :