mod_google_analyticsはずぼらWebサイト管理になくてはならないモジュールだ。
昨日の非同期トラッキングにあわせてクイックハックしてみたので晒してみる。
昨日の非同期トラッキングにあわせてクイックハックしてみたので晒してみる。
% diff -u mod_google_analytics.c.orig mod_google_analytics.c
--- mod_google_analytics.c.orig 2009-05-09 00:39:34.000000000 +0900
+++ mod_google_analytics.c 2009-12-02 15:57:53.000000000 +0900
@@ -46,12 +46,12 @@
#include "apr_strmatch.h"
#include "apr_strings.h"
-#define VERSION "0.2"
+#define VERSION "0.2-async"
static const char *google_analytics_filter_name = "GOOGLE_ANALYTICS";
-static const char *body_end_tag = "</body>";
+static const char *body_end_tag = "</head>";
static const unsigned int body_end_tag_length = 7;
-static const char *replace_base = "<script type=\"text/javascript\"><!-- \n 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\"));\n//--></script><script type=\"text/javascript\"><!-- \n try {var pageTracker = _gat._getTracker(\"%s\");pageTracker._trackPageview();} catch(err) {}; \n//--></script></body>";
+static const char *replace_base = "<script type=\"text/javascript\">\n var _gaq = _gaq || [];\n _gaq.push(['_setAccount', '%s']);\n _gaq.push(['_trackPageview']);\n (function() {\n var ga = document.createElement('script');\n ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';\n ga.setAttribute('async', 'true');\n document.documentElement.firstChild.appendChild(ga);\n })();\n</script>\n</head>";
static const char *tag_exists = "google-analytics\\.com/(ga|urchin)\\.js";
static const ap_regex_t *regex_tag_exists;
static const apr_strmatch_pattern *pattern_body_end_tag;
mod_google_analytics-0.2-async.diffをダウンロード
インストールはパッケージのMakefileを使わず,% sudo apxs -i -a -c mod_google_analytics.cとした。とりあえず今のところ動いている。
いい気になって作者にパッチを送ってしまった。


コメント