diff --git a/r2/r2/controllers/front.py b/r2/r2/controllers/front.py index 081c19885..80f4678f6 100755 --- a/r2/r2/controllers/front.py +++ b/r2/r2/controllers/front.py @@ -1321,7 +1321,7 @@ class FormsController(RedditController): g.log.info("just set payment_blob-%s" % passthrough) return BoringPage(_("reddit gold"), - show_sidebar = False, + show_sidebar=False, content=GoldPayment(goldtype, period, months, signed, recipient, giftmessage, passthrough) diff --git a/r2/r2/public/static/js/analytics.js b/r2/r2/public/static/js/analytics.js index b9fa10cb0..013bdc8bd 100644 --- a/r2/r2/public/static/js/analytics.js +++ b/r2/r2/public/static/js/analytics.js @@ -10,6 +10,8 @@ r.analytics = { ) $('.promotedlink.promoted:visible, .sponsorshipbox:visible').trigger('onshow') + $('form.google-checkout').on('submit', this.fireGoogleCheckout) + $('form.gold-checkout').one('submit', this.fireGoldCheckout) }, fetchTrackingHashes: function(callback) { @@ -121,6 +123,32 @@ r.analytics = { r.analytics.breadcrumbs.toParams() ) ) + }, + + fireGoldCheckout: function(event) { + var form = $(this), + vendor = form.data('vendor') + form.parent().addClass('working') + + // Track a virtual pageview indicating user went off-site to "vendor." + // If GA is loaded, have GA process form submission after firing + // (and cancel the default). + _gaq.push(['_trackPageview', '/gold/external/' + vendor]) + _gaq.push(function(){ form.submit() }) + + if (_gat && _gat._getTracker){ + // GA is loaded; form will submit via the _gaq.push'ed function + event.preventDefault() + } + }, + + fireGoogleCheckout: function(event) { + var form = $(this) + form.parent().addClass('working') + _gaq.push(function(){ + var pageTracker = _gaq._getAsyncTracker() + setUrchinInputCode(pageTracker) + }) } } diff --git a/r2/r2/templates/goldpayment.html b/r2/r2/templates/goldpayment.html index c8e16e023..7510aea0d 100644 --- a/r2/r2/templates/goldpayment.html +++ b/r2/r2/templates/goldpayment.html @@ -57,6 +57,8 @@ %if thing.google_id:
%endif