0
최근 Google 웹 로그 분석을 사용하여 '단일 페이지 웹 사이트'에서 사용자를 추적하는 데 문제가 있습니다. 내 솔루션을 공유하고 싶습니다. 아래 답변을 참조하십시오.Google 웹 로그 분석으로 단일 페이지 웹 사이트에서 사용자 추적
최근 Google 웹 로그 분석을 사용하여 '단일 페이지 웹 사이트'에서 사용자를 추적하는 데 문제가 있습니다. 내 솔루션을 공유하고 싶습니다. 아래 답변을 참조하십시오.Google 웹 로그 분석으로 단일 페이지 웹 사이트에서 사용자 추적
최근 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>
----- 요구 -----
---- 알고리즘 ----- 페이지
---- 예제 코드는 -----
<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에보고됩니다 "/ 제-장 제목 /"
당신은 * 질문에이를 분리 할 수 *와 * 대답*. Google 애널리틱스가 버튼 푸시 이벤트에 대한 추적 이벤트를 보내기 시작할 때 단일 페이지 계산기 사이트 방문 횟수가 정기적으로 방문으로 바뀌 었음을 다시 한 번 확인했습니다. Google에 조금 더 많은 정보를 제공하고 추적 할 수있는 것은 덜 분명한 방법. – Paul