Javascript Redirect with Google Analytics

后端 未结 9 679
暗喜
暗喜 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:00

    I'd suggest changing your Google Analytics code to be synchronous instead of asychronous by changing it to this:

    
    
    

    This should guarantee that it runs before your redirect code kicks in and it should be out of the way of your redirect script so there is no interference. As you have it now, you're playing a guessing game for how long the GA script will take to load and that it will load and do it's job in under 3 seconds. That may usually be the case, but there is no reason to load it asynchronously like you are and have to play that game. Load it synchronously and it will do it's job before your javascript redirect fires.

    It might even be possible to just put the redirect directly after the GA code like this and minimize the time that your placeholder page is displayed:

    
    
    
    

提交回复
热议问题