Google Analytics tracking support for Pro users' blogs.
parent
f5bc4c66be
commit
f47ffb8b08
|
@ -0,0 +1,75 @@
|
||||||
|
# -*- coding: 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 'UserProfile.google_analytics_tracking_id'
|
||||||
|
db.add_column('accounts_userprofile', 'google_analytics_tracking_id',
|
||||||
|
self.gf('django.db.models.fields.CharField')(max_length=250, null=True, blank=True),
|
||||||
|
keep_default=False)
|
||||||
|
|
||||||
|
|
||||||
|
def backwards(self, orm):
|
||||||
|
# Deleting field 'UserProfile.google_analytics_tracking_id'
|
||||||
|
db.delete_column('accounts_userprofile', 'google_analytics_tracking_id')
|
||||||
|
|
||||||
|
|
||||||
|
models = {
|
||||||
|
'accounts.userprofile': {
|
||||||
|
'Meta': {'object_name': 'UserProfile'},
|
||||||
|
'blog_domain': ('django.db.models.fields.CharField', [], {'max_length': '250', 'null': 'True', 'blank': 'True'}),
|
||||||
|
'blog_theme': ('django.db.models.fields.CharField', [], {'default': "'D'", 'max_length': '1'}),
|
||||||
|
'blog_title': ('django.db.models.fields.CharField', [], {'max_length': '250', 'null': 'True', 'blank': 'True'}),
|
||||||
|
'default_editor': ('django.db.models.fields.CharField', [], {'default': "'C'", 'max_length': '250'}),
|
||||||
|
'disqus_shortname': ('django.db.models.fields.CharField', [], {'max_length': '250', 'null': 'True', 'blank': 'True'}),
|
||||||
|
'gittip_username': ('django.db.models.fields.CharField', [], {'max_length': '250', 'null': 'True', 'blank': 'True'}),
|
||||||
|
'google_analytics_tracking_id': ('django.db.models.fields.CharField', [], {'max_length': '250', 'null': 'True', 'blank': 'True'}),
|
||||||
|
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||||
|
'is_pro': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||||
|
'stripe_id': ('django.db.models.fields.CharField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
|
||||||
|
'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'unique': 'True'})
|
||||||
|
},
|
||||||
|
'auth.group': {
|
||||||
|
'Meta': {'object_name': 'Group'},
|
||||||
|
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||||
|
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
|
||||||
|
'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
|
||||||
|
},
|
||||||
|
'auth.permission': {
|
||||||
|
'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
|
||||||
|
'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||||
|
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
|
||||||
|
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||||
|
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
|
||||||
|
},
|
||||||
|
'auth.user': {
|
||||||
|
'Meta': {'object_name': 'User'},
|
||||||
|
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
|
||||||
|
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
|
||||||
|
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
|
||||||
|
'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
|
||||||
|
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||||
|
'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
|
||||||
|
'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||||
|
'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||||
|
'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
|
||||||
|
'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
|
||||||
|
'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
|
||||||
|
'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
|
||||||
|
'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
|
||||||
|
},
|
||||||
|
'contenttypes.contenttype': {
|
||||||
|
'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
|
||||||
|
'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||||
|
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||||
|
'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||||
|
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
complete_apps = ['accounts']
|
|
@ -24,5 +24,6 @@ class UserProfile(models.Model):
|
||||||
|
|
||||||
gittip_username = models.CharField(max_length=250, null=True, blank=True)
|
gittip_username = models.CharField(max_length=250, null=True, blank=True)
|
||||||
disqus_shortname = models.CharField(max_length=250, null=True, blank=True)
|
disqus_shortname = models.CharField(max_length=250, null=True, blank=True)
|
||||||
|
google_analytics_tracking_id = models.CharField(max_length=250, null=True, blank=True)
|
||||||
|
|
||||||
User.profile = property(lambda u: UserProfile.objects.get_or_create(user=u)[0])
|
User.profile = property(lambda u: UserProfile.objects.get_or_create(user=u)[0])
|
||||||
|
|
|
@ -64,6 +64,13 @@
|
||||||
<span class="help-block">If you have your own <a href="http://disqus.com/">Disqus</a> account that you'd like to use for your blog comments, enter your shortname here.</span>
|
<span class="help-block">If you have your own <a href="http://disqus.com/">Disqus</a> account that you'd like to use for your blog comments, enter your shortname here.</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label" for="id_google_analytics_tracking_id">Google Analytics tracking ID:</label>
|
||||||
|
<div class="controls">
|
||||||
|
{{ form.google_analytics_tracking_id }}
|
||||||
|
<span class="help-block">If you'd like to track visits to your blog site with <a href="http://analytics.google.com">Google Analytics</a>, enter your tracking ID here.</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<button type="submit" class="btn btn-success">Save</button>
|
<button type="submit" class="btn btn-success">Save</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -29,6 +29,7 @@ def account(request):
|
||||||
|
|
||||||
'gittip_username': profile.gittip_username,
|
'gittip_username': profile.gittip_username,
|
||||||
'disqus_shortname': profile.disqus_shortname,
|
'disqus_shortname': profile.disqus_shortname,
|
||||||
|
'google_analytics_tracking_id': profile.google_analytics_tracking_id,
|
||||||
})
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -78,10 +78,10 @@
|
||||||
</aside>
|
</aside>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block analytics %}
|
{% block analytics %}
|
||||||
{% if blog_user.username == 'rochacbruno' %}
|
{% if blog_user.profile.google_analytics_tracking_id %}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var _gaq = _gaq || [];
|
var _gaq = _gaq || [];
|
||||||
_gaq.push(['_setAccount', 'UA-33970092-1']);
|
_gaq.push(['_setAccount', '{{ blog_user.profile.google_analytics_tracking_id }}']);
|
||||||
_gaq.push(['_trackPageview']);
|
_gaq.push(['_trackPageview']);
|
||||||
(function() {
|
(function() {
|
||||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||||
|
|
|
@ -122,6 +122,18 @@
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if blog_user.profile.google_analytics_tracking_id %}
|
||||||
|
<script type="text/javascript">
|
||||||
|
var _gaq = _gaq || [];
|
||||||
|
_gaq.push(['_setAccount', '{{ blog_user.profile.google_analytics_tracking_id }}']);
|
||||||
|
_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 %}
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
<li>Exclusive Pro-only theme for your blog. <a href="http://nicksergeant.com/">Here's a preview</a> of the first available theme (working on more).</li>
|
<li>Exclusive Pro-only theme for your blog. <a href="http://nicksergeant.com/">Here's a preview</a> of the first available theme (working on more).</li>
|
||||||
<li><a href="https://www.gittip.com/">GitTip</a> integration ("tip" link on every snipt next to your username, and on your profile). <a href="https://snipt.net/nick/">Sample</a>.</li>
|
<li><a href="https://www.gittip.com/">GitTip</a> integration ("tip" link on every snipt next to your username, and on your profile). <a href="https://snipt.net/nick/">Sample</a>.</li>
|
||||||
<li>Ability to use your own <a href="http://disqus.com">Disqus</a> account for comments on your Snipt blog.</li>
|
<li>Ability to use your own <a href="http://disqus.com">Disqus</a> account for comments on your Snipt blog.</li>
|
||||||
|
<li>Ability to use your own <a href="http://analytics.google.com">Google Analytics</a> account for tracking visits to your Snipt blog.</li>
|
||||||
</ul>
|
</ul>
|
||||||
{% if request.user.profile.is_pro %}
|
{% if request.user.profile.is_pro %}
|
||||||
<h3>You're already a Pro. You know that ;)</h3>
|
<h3>You're already a Pro. You know that ;)</h3>
|
||||||
|
|
Loading…
Reference in New Issue