Jeremy Newman : load google analytics if defined in config

Jeremy Newman jnewman at winehq.org
Thu Apr 12 14:53:42 CDT 2012


Module: website
Branch: master
Commit: d8bc1bd004bb4f5bb831f3e6443c1997374e2fd8
URL:    http://source.winehq.org/git/website.git/?a=commit;h=d8bc1bd004bb4f5bb831f3e6443c1997374e2fd8

Author: Jeremy Newman <jnewman at codeweavers.com>
Date:   Thu Apr 12 14:44:24 2012 -0500

load google analytics if defined in config

---

 include/plugins/google_analytics.php          |   19 +++++++++++++++++++
 templates/en/global/google_analytics.template |   10 ++++++++++
 2 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/include/plugins/google_analytics.php b/include/plugins/google_analytics.php
new file mode 100644
index 0000000..2850afb
--- /dev/null
+++ b/include/plugins/google_analytics.php
@@ -0,0 +1,19 @@
+<?php
+
+/*
+ * WineHQ.org
+ * by Jeremy Newman <jnewman at codeweavers.com>
+ */
+
+/*
+    Loads Google Analytics Statistics
+*/
+
+if (!empty($config->google_analytics))
+{
+    // display the google analytics code
+    echo $html->template("local", "global/google_analytics", array('gcode' => $config->google_analytics));
+}
+
+// done
+?>
diff --git a/templates/en/global/google_analytics.template b/templates/en/global/google_analytics.template
new file mode 100644
index 0000000..bd6624a
--- /dev/null
+++ b/templates/en/global/google_analytics.template
@@ -0,0 +1,10 @@
+    <script type="text/javascript">
+    var _gaq = _gaq || [];
+    _gaq.push(['_setAccount', '{$gcode}']);
+    _gaq.push(['_trackPageview']);
+    (function(){
+        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+    })();
+    </script>




More information about the wine-cvs mailing list