Commits

Luke Plant committed 2bc4a80

Added Google analytics

Comments (0)

Files changed (3)

christchurch/processors.py

+from django.conf import settings
+
+def common(request):
+    return {'GOOGLE_ANALYTICS_ACCOUNT': getattr(settings, 'GOOGLE_ANALYTICS_ACCOUNT', '')}
+

christchurch/settings.py

 if DEVBOX:
     MEDIA_ROOT = os.path.join(parentdir, 'usermedia')
 else:
-    from .settings_priv import MEDIA_ROOT
+    from .settings_priv import MEDIA_ROOT, GOOGLE_ANALYTICS_ACCOUNT
 
 MEDIA_URL = '/usermedia/'
 STATIC_URL = '/static/'
     'django.core.context_processors.media',
     'django.core.context_processors.static',
     'cms.context_processors.media',
+    'christchurch.processors.common',
 )
 
 ROOT_URLCONF = 'christchurch.urls'

christchurch/templates/standard.html

   <link rel="StyleSheet" href="{{ STATIC_URL }}christchurch/css/style.css" type="text/css">
 
   {% plugins_media %}
+  {% if GOOGLE_ANALYTICS_ACCOUNT %}
+<script type="text/javascript">
 
+  var _gaq = _gaq || [];
+  _gaq.push(['_setAccount', '{{ GOOGLE_ANALYTICS_ACCOUNT }}']);
+  _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>
+  {% endif %}
 </head>