root/platform/tdiary/plugin/google_analytics.rb

Revision 11283, 1.2 kB (checked in by drry, 7 months ago)
  • ちょっとした変更です。
Line 
1#
2# Google Analytics plugin for tDiary
3#
4# Copyright (C) 2005 TADA Tadashi <sho@spc.gr.jp>
5# You can redistribute it and/or modify it under GPL2.
6#
7if /^(?:latest|day|month|nyear)$/ =~ @mode then
8        add_footer_proc do
9                google_analytics_insert_code
10        end
11end
12
13def google_analytics_insert_code
14        return '' unless @conf['google_analytics.profile']
15        <<-HTML
16        <script type="text/javascript"><!--
17        var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.") ;
18        document.write(unescape('%3Cscript src="' + gaJsHost + 'google-analytics.com/ga.js" type="text/javascript"%3E%3C/script%3E')) ;
19        // --></script>
20        <script type="text/javascript"><!--
21        var pageTracker = _gat._getTracker("UA-#{h @conf['google_analytics.profile']}");
22        pageTracker._initData();
23        pageTracker._trackPageview();
24        // --></script>
25        HTML
26end
27
28# UA-53836-1
29add_conf_proc( 'google_analytics', 'Google Analytics' ) do
30        if @mode == 'saveconf' then
31                @conf['google_analytics.profile'] = @cgi.params['google_analytics.profile'][0]
32        end
33        <<-HTML
34                <h3>Google Analytics Profile</h3>
35                <p>set your Profile ID (NNNNN-N)</p>
36                <p><input name="google_analytics.profile" value="#{h @conf['google_analytics.profile']}"></p>
37        HTML
38end
Note: See TracBrowser for help on using the browser.