Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #4 from acdha/page-load-time

Initial integration of the new page-load tracker
  • Loading branch information...
commit 140787ba86ef4995b2cabf927bf0b56ec7728348 2 parents e835a1e + 45a1282
Clint Ecker authored
View
7 README.mdown
@@ -49,6 +49,13 @@ This is being added as an option rather than a replacement for two reasons:
Adding the asynchronous tracking to existing code would cause backwards
incompatiblity.
+## Tracking Page-Load Time ##
+
+Google has added [page-load tracking](http://www.google.com/support/analyticshelp/bin/answer.py?hl=en&answer=1205784&topic=1120718).
+To use this feature add the following to your settings file:
+
+ GOOGLE_ANALYTICS_TRACK_PAGE_LOAD_TIME = True
+
## Supporting other tracking methods ##
Sometimes, the built-in code snippets are not sufficient for what you want to
View
4 google_analytics/templates/google_analytics/analytics_async_template.html
@@ -3,6 +3,10 @@
_gaq.push(['_setAccount', '{{ analytics_code }}']);
_gaq.push(['_trackPageview']);
+ {% if track_page_load_time %}
+ _gaq.push(['_trackPageLoadTime']);
+ {% endif %}
+
(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';
View
3  google_analytics/templates/google_analytics/analytics_template.html
@@ -6,4 +6,7 @@
var pageTracker = _gat._getTracker("{{ analytics_code }}");
pageTracker._initData();
pageTracker._trackPageview();
+{% if track_page_load_time %}
+ pageTracker._trackPageLoadTime();
+{% endif %}
</script>
View
4 google_analytics/templatetags/analytics.py
@@ -1,4 +1,5 @@
from django import template
+from django.conf import settings
from django.db import models
from django.contrib.sites.models import Site
@@ -53,6 +54,9 @@ def render(self, context):
t = loader.get_template(self.template_name)
c = Context({
'analytics_code': code,
+ 'track_page_load_time': getattr(settings,
+ "GOOGLE_ANALYTICS_TRACK_PAGE_LOAD_TIME",
+ False),
})
return t.render(c)
else:
Please sign in to comment.
Something went wrong with that request. Please try again.