2015-01-31 3 views
0

최근 Google 웹 로그 분석을 사용하여 '단일 페이지 웹 사이트'에서 사용자를 추적하는 데 문제가 있습니다. 내 솔루션을 공유하고 싶습니다. 아래 답변을 참조하십시오.Google 웹 로그 분석으로 단일 페이지 웹 사이트에서 사용자 추적

+0

당신은 * 질문에이를 분리 할 수 ​​*와 * 대답*. Google 애널리틱스가 버튼 푸시 이벤트에 대한 추적 이벤트를 보내기 시작할 때 단일 페이지 계산기 사이트 방문 횟수가 정기적으로 방문으로 바뀌 었음을 다시 한 번 확인했습니다. Google에 조금 더 많은 정보를 제공하고 추적 할 수있는 것은 덜 분명한 방법. – Paul

답변

0

최근 Google 애널리틱스를 사용하여 '단일 페이지 웹 사이트'에서 사용자를 추적하는 데 문제가 있습니다. 내 솔루션을 공유하고 싶습니다. 페이지가 너무 아래로 스크롤 할 때

----- 페이지 레이아웃 -----

1a. Header with logo and menu (links scroll page down to selected chapter) 
2a. Section with big paralax bakground 
2b. Chapter header <section><h2>Title 1</h2></section> 
2c. Chapter's content <div>content</div> 
3a. Section with big paralax bakground 
3b. Chapter header <section><h2>Title 2</h2></section> 
3c. Chapter's content <div>content</div> 
... 
Na. Section with big paralax bakground 
Nb. Chapter header <section><h2>Title N</h2></section> 
Nc. Chapter's content <div>content</div> 

----- 요구 -----

  1. 알고리즘 감지한다 선택한 장은 사용자가 볼 수 있습니다.
  2. 알고리즘은 사용자가 장의 내용에 익숙해 지려면 실제로 시간을 들여야 함을 감지해야합니다. 이 사실을 Google 웹 로그 분석에보고해야합니다.
  3. 알고리즘은 사용자가 챕터를 스크롤 할 때 챕터를 읽었 음을보고 할 수 없습니다.

---- 알고리즘 ----- 페이지

  1. 기다립니다
  2. 챕터의 목록을 작성로드하고이 웹 사이트의 위쪽 테두리 관련 위치입니다.
  3. 사용자가 원하는 장을 볼 수있을 때 사용자가 실제로 콘텐츠를 읽는 데 실제로 시간을 보내고 있음을 증명하기 위해 일정 기간 후에이 조건을 다시 검사해야합니다.
  4. 위의 조건이 충족되면이 사실을 Google 애널리틱스에보고하는 것보다 높습니다.

---- 예제 코드는 -----

<script type="text/javascript"> 

var scrollstat = [] 

// Preparing array of chapters and positions 
$(document).ready(function() { 
    $("section").each(function() { 
     var ts = {}; 
     ts["offset"] = $(this).offset(); 
     str = $("h2", this).html(); 
     ts["name"] = "SECTION-"+str.replace(" ","-")+"/"; 
     ts["checked"] = false; 
     ts["timer"] = false; 
     scrollstat.push(ts); 
    }); 
}); 

//Checking that user is still on the same chapter 
function doublecheck(ii) { 
    scrollpos = $(window).scrollTop(); 
    max = scrollpos + 300; 
    min = scrollpos; 
    if (scrollstat[ii].checked == false && scrollstat[ii].offset.top > min 
    && scrollstat[ii].offset.top < max) { 
     _gaq.push(['_trackPageview', (location.pathname + location.search 
     + scrollstat[ii].name)]); 
     scrollstat[ii].checked = true; 
    } 
    console.log(scrollstat[ii].offset.top+','+min+','+max); 
    scrollstat[ii].timer = false; 
} 


//Separate function for setting timer to count 3s 
//If user don't scroll to other chapter within this time 
//event is reported to GA 

function settimer(ii) { 
    scrollstat[ii].timer = true; 
    setTimeout(function() {doublecheck(ii);},3000); 
} 

//Handling scrolling event 
$(window).scroll(function() { 
    scrollpos = $(window).scrollTop(); 
    max = scrollpos + 300; 
    min = scrollpos; 
    for (index = 0; index < scrollstat.length; ++index) { 
     if (scrollstat[index].checked == false && 
     scrollstat[index].timer == false && 
     scrollstat[index].offset.top > min && 
     scrollstat[index].offset.top < max) { 
       settimer(index); 
     } 
    } 
}); 

</script> 

MAX와 MIN 변수는 실험적으로 추정된다. 제 경우에는 장 제목이 화면 상단으로 스크롤되어야한다고 가정했습니다.

위의 스크립트의 결과는, 각각의 챕터는 같은 주소를 별도의 페이지 방문으로 GA에보고됩니다 "/ 제-장 제목 /"

관련 문제