Can my Google Analytics code be compressed?

Discussion in 'JavaScript' started by tobydawson13, Jan 5, 2009.

  1. #1
    Hi would it be possible to compress my Google Analytics code, so that it was all on one line? Thankyou for your time :D

    <script type="text/javascript">
    var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
    document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
    </script>
    <script type="text/javascript">
    var pageTracker = _gat._getTracker("UA-6797325-1");
    pageTracker._initData();
    pageTracker._trackPageview();
    </script>
    Code (markup):
     
    tobydawson13, Jan 5, 2009 IP
  2. ignas2526

    ignas2526 Peon

    Messages:
    75
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Here is your code in one line
    <script type="text/javascript">var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");var pageTracker = _gat._getTracker("UA-6797325-1");document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));pageTracker._initData();pageTracker._trackPageview();</script>
    Code (markup):
    If you want even more compression, here is code whiteout some spaces:
    <script type="text/javascript">var gaJsHost=(("https:"==document.location.protocol)?"https://ssl.":"http://www.");var pageTracker=_gat._getTracker("UA-6797325-1");document.write(unescape("%3Cscript src='"+gaJsHost+"google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));pageTracker._initData();pageTracker._trackPageview();</script>
    Code (markup):
     
    ignas2526, Jan 5, 2009 IP
  3. tobydawson13

    tobydawson13 Active Member

    Messages:
    645
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    60
    #3
    Thank you Ignas2526 :D
     
    tobydawson13, Jan 5, 2009 IP