From d89fb17b03b2e2c0fb1da77fb13cc660a5b6c9d1 Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Mon, 10 Feb 2014 14:14:45 -0700 Subject: [PATCH] feat(event-tracking): track ecommerce events --- src/controllers/user.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/controllers/user.js b/src/controllers/user.js index 9ca65c1056..eed05a6b9f 100644 --- a/src/controllers/user.js +++ b/src/controllers/user.js @@ -295,7 +295,6 @@ api.buyGems = function(req, res, next) { function(response, cb) { //user.purchased.ads = true; if (req.query.plan) { - ga.event('subscribe', 'Stripe').send() user.purchased.plan = { planId:'basic_earned', customerId: response.id, @@ -303,9 +302,12 @@ api.buyGems = function(req, res, next) { dateUpdated: new Date, gemsBought: 0 }; + ga.event('subscribe', 'Stripe').send() + ga.transaction(response.id, 5).item(5, 1, "stripe-subscription", "Subscription > PayPal").send() } else { - ga.event('checkout', 'Stripe').send() user.balance += 5; + ga.event('checkout', 'Stripe').send() + ga.transaction(response.id, 5).item(5, 1, "stripe-checkout", "Gems > Stripe").send() } user.save(cb); } @@ -356,6 +358,7 @@ api.buyGemsPaypalIPN = function(req, res, next) { user.save(); logging.info('PayPal transaction completed and user updated'); ga.event('checkout', 'PayPal').send() + ga.transaction(req.body.txn_id, 5).item(5, 1, "paypal-checkout", "Gems > PayPal").send() }); } });