title: Redirect page with Google analytics
body: <p>I have a page that redirects the user to three different pages with this script:</p>
  
  <pre><code>&lt;html&gt;
  &lt;body&gt;
  &lt;/body&gt;
  &lt;script src="jquery.js"&gt;&lt;/script&gt;
  &lt;script&gt;
  $(document).ready(function (){
          var redirected = false;
         if(navigator.userAgent.toLowerCase().indexOf("android") &gt; -1){
             redirected = true;
             console.log("hello andorid");
  
             window.location.href = 'http://android.web.site.com';
          }
          if(navigator.userAgent.toLowerCase().indexOf("iphone") &gt; -1){
              redirected = true;
              console.log("hello iphone");
              window.location.href = "http://iphone.web.site.com";
          }
          if(navigator.userAgent.toLowerCase().indexOf("ipad") &gt; -1){
              redirected = true;
              console.log("hello ipad");
              window.location.href = "http://ipad.web.site.com";
          }
          if(navigator.userAgent.toLowerCase().indexOf("ipod") &gt; -1){
              redirected = true;
              console.log("hello iphone");
              window.location.href = "http://ipod.web.site";
          }
          else if(redirected==false){
              console.log("hello windows");
              window.location.href = "app.html";
  
          }
      });
  &lt;/script&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>So it checks if the user is on a mobile phone. Now the customer wants to track how many users clicks on that page, and how many users that lands on the "app.html" page.</p>
  
  <p>I was thinking on setting the Google analytics script inside the <code>&lt;body&gt;</code> tags. Is that correct? Do I need to set a timeout on the redirect script so GA can have time to launch properly? </p>
  
  <p>I'm quite fresh with analytics, and I've seen this page: <a href="https://support.google.com/analytics/answer/1009614?hl=en" rel="nofollow">https://support.google.com/analytics/answer/1009614?hl=en</a> but I don't know if that is suitable for me.</p>
  
  <p>Grateful for any help.</p>