diff --git a/googletools/migrations/0002_auto__add_field_analyticscode_speed.py b/googletools/migrations/0002_auto__add_field_analyticscode_speed.py new file mode 100644 index 0000000..8cee83a --- /dev/null +++ b/googletools/migrations/0002_auto__add_field_analyticscode_speed.py @@ -0,0 +1,43 @@ +# encoding: utf-8 +import datetime +from south.db import db +from south.v2 import SchemaMigration +from django.db import models + +class Migration(SchemaMigration): + + def forwards(self, orm): + + # Adding field 'AnalyticsCode.speed' + db.add_column('googletools_analyticscode', 'speed', self.gf('django.db.models.fields.BooleanField')(default=False), keep_default=False) + + + def backwards(self, orm): + + # Deleting field 'AnalyticsCode.speed' + db.delete_column('googletools_analyticscode', 'speed') + + + models = { + 'googletools.analyticscode': { + 'Meta': {'ordering': "('site', 'code')", 'object_name': 'AnalyticsCode'}, + 'code': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'site': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['sites.Site']", 'unique': 'True'}), + 'speed': ('django.db.models.fields.BooleanField', [], {'default': 'False'}) + }, + 'googletools.siteverificationcode': { + 'Meta': {'ordering': "('site', 'code')", 'object_name': 'SiteVerificationCode'}, + 'code': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'site': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['sites.Site']", 'unique': 'True'}) + }, + 'sites.site': { + 'Meta': {'ordering': "('domain',)", 'object_name': 'Site', 'db_table': "'django_site'"}, + 'domain': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) + } + } + + complete_apps = ['googletools'] diff --git a/googletools/models.py b/googletools/models.py index 7d6829f..9721413 100644 --- a/googletools/models.py +++ b/googletools/models.py @@ -6,6 +6,7 @@ class AnalyticsCode(models.Model): site = models.ForeignKey(Site, verbose_name=_('site'), unique=True) code = models.CharField(_('code'), max_length=100) + speed = models.BooleanField(verbose_name=_('track speed'), default=False) def __unicode__(self): return self.code diff --git a/googletools/templates/googletools/analytics_code.html b/googletools/templates/googletools/analytics_code.html index ea773d3..6b29832 100644 --- a/googletools/templates/googletools/analytics_code.html +++ b/googletools/templates/googletools/analytics_code.html @@ -3,6 +3,7 @@ var _gaq = _gaq || []; _gaq.push(['_setAccount', '{{ analytics_code }}']); _gaq.push(['_trackPageview']); + {% if analytics_code.speed %}_gaq.push(['_trackPageLoadTime']);{% endif %} (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;