2010-06-22 4 views
1

Google 애널리틱스의 새로운 비동기 코드를 사용하고 있습니다. 동일한 페이지에서 GA.js를 두 번 호출하는 것이 맞겠습니까? 그렇지 않으면 할 수있는 방법이 있습니까?Google 웹 로그 분석 비동기 코드

내 문제는 플래시를 사용하여 예약 양식에 두 개의 PageViews를 계정해야하는데 문제는 사용자가 두 번째 단계로 이동하지 않아도되지만 첫 번째 단계에서 창을 닫을 수 있다는 점입니다.

<!-- Step one, I need to record a pageview --> 

    var _gaq = _gaq || []; 
    _gaq.push(['_setAccount', 'UA-6173481-3']); 
    _gaq.push(['_trackPageview', '/Step1']); 
    (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); 
    })(); 

    <!-- Step two of the process i define a function that will get called by flash and record another pageview--> 

    function completed(){ 

    var _gaq = _gaq || []; 
    _gaq.push(['_setAccount', 'UA-6173481-3']); 
    _gaq.push(['_trackPageview', '/Step2']); 
    (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); 
    })(); 

    } 

답변

1

다음 작업을해야합니다 : 원하는 경우

<!-- Step one, I need to record a pageview --> 
    var _gaq = _gaq || []; 
    _gaq.push(['_setAccount', 'UA-6173481-3']); 
    _gaq.push(['_trackPageview', '/Step1']); 
    (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); 
    })(); 

    <!-- Step two of the process i define a function that will get called by flash and record another pageview--> 
    function completed(){ 
    _gaq.push(['_trackPageview', '/Step2']);  
    } 

그런 다음 플래시에서 completed()를 호출합니다.

관련 문제