Track donations in google analytics
This commit is contained in:
@@ -3,5 +3,5 @@ from django.conf.urls.defaults import patterns, include, url
|
||||
urlpatterns = patterns('donate',
|
||||
url(r'^$', 'views.index'),
|
||||
url(r'^dwolla$', 'views.dwollaCallback'),
|
||||
url(r'^thanks$', 'views.thanks'),
|
||||
url(r'^thanks/(?P<donation>.+)$', 'views.thanks'),
|
||||
)
|
||||
|
@@ -34,9 +34,9 @@ def index(request):
|
||||
data['Key'] = settings.DWOLLA_API_KEY
|
||||
data['Secret'] = settings.DWOLLA_API_SECRET
|
||||
data['Callback'] = 'http://camin.us%s'%reverse('donate.views.dwollaCallback')
|
||||
data['Redirect'] = 'http://camin.us%s'%reverse('donate.views.thanks')
|
||||
donation = models.Donation.objects.create(quantity=form.cleaned_data['quantity'], user=request.user)
|
||||
order['OrderId'] = donation.id
|
||||
data['Redirect'] = 'http://camin.us%s'%reverse('donate.views.thanks', donation.id)
|
||||
req = urllib2.Request("https://www.dwolla.com/payment/request", data=json.dumps(data), headers={'Content-Type': 'application/json'})
|
||||
response = json.load(urllib2.urlopen(req))
|
||||
return HttpResponseRedirect("https://www.dwolla.com/payment/checkout/%s"%(response['CheckoutId']))
|
||||
@@ -57,5 +57,6 @@ def dwollaCallback(request):
|
||||
notification.send_now([donation.user], "donation_paid", {"donation":donation, "credit":donation.quantity*2000})
|
||||
return HttpResponse(status=204)
|
||||
|
||||
def thanks(request):
|
||||
return render_to_response('donate/thanks.html')
|
||||
def thanks(request, donation):
|
||||
donationObj = models.Donation.objects.get(id=donation)
|
||||
return render_to_response('donate/thanks.html', {'donation': donationObj}, context_instance = RequestContext(request))
|
||||
|
11
templates/donate/thanks.html
Normal file
11
templates/donate/thanks.html
Normal file
@@ -0,0 +1,11 @@
|
||||
{% extends 'base_simple.html' %}
|
||||
|
||||
{% block extraAnalytics %}
|
||||
_gaq.push(['_addTrans', '{{donation.id}}', '', '{{donation.quantity}}', '0.00', '0.00', '', '', '']);
|
||||
_gaq.push(['_addItem', '{{donation.id}}', 'donation', 'Donation', '', '{{donation.quantity}}', '1']);
|
||||
_gaq.push(['_trackTrans']);
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
Thanks for donating!
|
||||
{% endblock %}
|
Reference in New Issue
Block a user