Update your Google Analytics Tracking Code

Just in case you missed the announcement from Google Analytics, they have just updated their tracking code snippet. The snippet is a couple of bits of JavaScript that first download the relevant copy of the analytics code (depending whether your site is SSL protected or not – so they don’t see security warnings from their browser) and then registers the visit with Google.

The change is simply to add some error handling to the JavaScript, so that if something goes wrong users will not see a warning method.

The new snippet is shown below, with the additional code in bold:

<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">
    try {
        var pageTracker = _gat._getTracker("UA-50020-1");
        pageTracker._trackPageview();
    } catch(err) {}
</script>

(I’ve just applied the change to the DSpace code repository, ready for the upcoming 1.5.2 release)

Bookmark and Share
Posted on January 17, 2009 at 7:55 pm by Stuart · Permalink
In: Uncategorized · Tagged with: ,

3 Responses

Subscribe to comments via RSS

  1. Written by Hardik Mishra
    on September 18, 2009 at 5:38 pm
    Permalink

    Hello Sir,

    Where to add above code ..
    In display-item.jsp

  2. Written by Stuart
    on September 18, 2009 at 5:44 pm
    Permalink

    In DSpace, the best place to put it is in the footer (layout/default-footer.jsp) as then it will be included in all pages.

  3. Written by sikiş izle , bedava izle
    on February 9, 2010 at 8:25 am
    Permalink

    thansks bunu altbilgi (düzen / default-footer.jsp) sonra tüm sayfaları dahil edilecek olduğu gibi koymak.

Subscribe to comments via RSS

Leave a Reply