set Timeout and Analytics

Discussion in 'Google Analytics' started by canldizitv, Oct 12, 2010.

  1. #1
    Hi dear friends ,

    Analytics show (0-10sn) %75 bounce rates on my web site.

    Because , the visitors just watching the video on my site and they close the browser after video . They dont explore the other pages

    I thought the solution as follows ..

    2 minutes after entering the page with the setTimeout value, a second Analytics code should work.

    I got run with the other functions with setTimeout code value but it would not work with Analytics code.

    This is the normal Analytics code .

    <script type="text/javascript">
    
      var _gaq = _gaq || [];
      _gaq.push(['_setAccount', 'UA-63XXXXX-3']);
      _gaq.push(['_setDomainName', '.site.com']);
      _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>
    
    Code (markup):
    And this is my code with SetTimeout

    <script type="text/javascript">
      var _gaq = _gaq || [];
      _gaq.push(['_setAccount', 'UA-63XXXXX-3']);
      _gaq.push(['_setDomainName', '.site.com']);
      _gaq.push(['_trackPageview']);
      setTimeout(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);
      },2000)();
    </script>
    
    Code (markup):
    I am looking it on mozilla Live-http-header but the code which has settimeout couldnt to connect google-analytics.com/ga.js.

    How can I solve this problem ?

    Thank you in advance.
     
    canldizitv, Oct 12, 2010 IP
  2. imperialDirectory

    imperialDirectory Peon

    Messages:
    395
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Just to verify what you are trying to accomplish here.

    So you want to track user for their initial visit (1st page view). Then 2 minutes later you want to track their visit again (2nd page view).

    Here's a sample you can try (not tested yet)
    
    setTimeout(function() {
        _gaq.push(['_trackPageview', '2nd_visit_name']);
    }, 2000)();
    
    Code (markup):
    Also note that 2000 is 2 seconds. I assumed you set it to 2000 just for testing purpose
     
    imperialDirectory, Oct 13, 2010 IP