2010-06-22 3 views
1

Я использую новый асинхронный код Google Analytics, было бы правильным называть GA.js дважды на одной странице, если нет, есть ли способ сделать это?Google Analytics Async Code

Моя проблема заключается в том, что мне нужна учетная запись на двух экранах в форме бронирования с использованием флеш-памяти, проблема в том, что пользователь может не обязательно попасть на второй этап, но закрыть окно на первом этапе.

<!-- 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() от вспышки, когда это необходимо.

Смежные вопросы