Updated GA.JS Tracking Code

I’ve gotten a lot of comments over the weekend about using the new ga.js code with ASP sites. It turns out that the code does not work with nested SP script tags. Also, the new tracking code that GA spits out is not XHTML compliant. These are unrelated issues that are causing a number of issues.

Google knows of these issues and will be pushing a solution soon. I’m not sure when, but soon. In the meantime, here is a copy of the new code that you should use on your site.

Remember, you need to replace “UA-xxxxx-x” with the appropriate information for your profile.

Sorry for the short post… I’m pretty tied up at work but wanted to post this information.

Props to Eivind Savio for sending me a nice email about the problem and a number of solutions.

Be Sociable, Share!

    Like this post? Sign up to get posts delivered to your inbox.


    1. says

      Hmm, the script block are gone. I meant this:

      <script type=”text/javascript” src=”http://www.google-analytics.com/ga.js”></script>


      <script type=”text/javascript” src=”https://ssl.google-analytics.com/ga.js”></script>

    2. says

      I just switched over to GA.js this past Friday on my legacy ASP-based site and had the same issue. My solution was the same.. split up the word “script” into two pieces so the idiotic VBScript parser doesn’t fail on something that’s not really a problem.

      Thanks Microsloth for trying to protect us from ourselves!

    3. Reid says

      More like: thanks, Google for not testing your product better before you rolled it out. I love Google, but to say I’ve been disappointed with this rollout of the new code would be a big understatement. It doesn’t even work with Blogger! That’s a Google product! Amazing.

      Anyway, thanks Justin for posting this info.

    4. says

      Appears crazy that Google would release this new analytics code before ensuring it was valid XHTML.

      Andre, can you explain what you meant in your post above about the script blocks? Are you saying these should be included?

    5. says


      You’re absolutely correct. You can use those simplified script tags to include the ga.js. The new code that I posted should also work.


      I agree 100%. It’s kind of amazing that Google would make this change.

      Thanks for the comments and thanks for reading.


    6. says

      @Paul, Justin explains what I meant. You can use those simplified script blocks in stead of the first script block Google suggests.

      @Justin: there’s an other problem with your solution: I miss the CDATA blocks, without them the new script is not XHTML Strict compliant.

      But, who cares about validation anyway ;)

    7. says

      Hey André,

      You’re right, the code I posted is not XHTML compliant. I chatted with Google and they need to decide between XHTML compliant and compatible with MSFT ASP script blocks. They decided to go with the latter.

      If you need XHTML compliant script you can add the CDATA blocks.

      I believe they’re pushing the code in the next day or so.


    8. Michael says

      When will the new event tracking feature be released to the public? I wrote all the code to do this and then found out it was in closed beta and it’s not available in my reports :(


    9. says

      Hi Michael,

      I’m not sure when the reporting side of event tracking will be released to the public. It’s a pretty big change for GA and I think they’re going to take it slow.


      The tracking code has been updated and should be working now. Check your profile settings to retrieve the correct version of ga.js.

      Thanks for reading,


    10. says

      Hi Justin,

      It looks like there is an extra space after “ssl” in the code you posted, which could lead to secured pages not beeing tracked:
      "https://ssl ." : "http://www.");




    1. […] Google announced a new version of the tracking code, ga.js, in October 2007 and launched the new code in December. After some minor launch problems things seem to be running smoothly. While you don’t need to migrate to ga.js, you should start to think about it because Google will no longer add features to urchin.js. In my opinion, you should tackle this problem sooner rather than later. […]

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>