Javascript Redirect with Google Analytics

后端 未结 9 710
暗喜
暗喜 2020-11-28 22:30

I need help figuring out how to successfully redirect while including Analytics code.

  • I have a subdomain setup http://buuf.fractalsystems.org
  • The subd
9条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-28 23:15

    The code provided by Mike works indeed. However, I found that removing the timer entirely works as well. The __utm.gif request is then aborted, but all information has been sent. The window just redirects and doesn't wait for the reply (which is simply a 200 status). I tested this and it seems to be working nicely.

    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-1234567-8']);
    _gaq.push(['_trackPageview']);
    _gaq.push(function() {
      window.location = "https://market.android.com/developer?pub=Fractal%20Systems";
    });
    
    
    (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);
    })();
    

提交回复
热议问题