From e264724f019cbf940cf9515848177324339b0493 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Espino?= Date: Thu, 19 Oct 2017 12:56:45 +0200 Subject: [PATCH] Fixing analytics checkout process --- app/coffee/modules/common/analytics.coffee | 46 ++++++++++++++++------ gulpfile.js | 2 +- 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/app/coffee/modules/common/analytics.coffee b/app/coffee/modules/common/analytics.coffee index 2040a9b6..7d3571f6 100644 --- a/app/coffee/modules/common/analytics.coffee +++ b/app/coffee/modules/common/analytics.coffee @@ -86,6 +86,9 @@ class AnalyticsService extends taiga.Service @win.ga("send", "event", category, action, label, value) addEcStep: (step, currentPlan, selectedPlan) -> + return if not @.initialized + return if not @win.ga + option = { "currentPlan": currentPlan, "selectedPlan": selectedPlan, @@ -109,6 +112,9 @@ class AnalyticsService extends taiga.Service @.trackEvent("ecommerce", "add-step", step, stepId) addEcImpression: (plan, page, position) -> + return if not @.initialized + return if not @win.ga + @win.ga('ec:addImpression', { 'id': plan.plan_id, 'name': plan.name, @@ -117,18 +123,36 @@ class AnalyticsService extends taiga.Service }) @.trackEvent("ecommerce", "add-impression", plan.name, plan.plan_id) - addEcProduct: (plan) -> - @win.ga('ec:addProduct', { - 'id': plan.plan_id, - 'name': plan.name, - 'position': 1, - }) - @.trackEvent("ecommerce", "add-product", plan.name, plan.plan_id) + addEcProduct: (plan_id, plan_name, plan_price) -> + return if not @.initialized + return if not @win.ga - setEcAction: (action, page) -> - @win.ga('ec:setAction', action, { - 'list': page + @win.ga('ec:addProduct', { + 'id': plan.plan_id, + 'name': plan.name, + 'price': plan.price, + 'category': "plans", + 'quantity': 1, + 'position': 1, }) - @.trackEvent("ecommerce", "set-action", (action+page), 0) + @win.ga('send', 'event', 'checkout', 'Collect Payment Info') + + addEcPurchase: (plan_id, plan_name, plan_price) -> + return if not @.initialized + return if not @win.ga + + @win.ga('ec:addProduct', { + 'id': plan_id, + 'name': plan_name, + 'price': plan_price, + 'category': "plans", + 'quantity': 1, + 'position': 1, + }) + @win.ga('ec:setAction','purchase', { + 'id': response.data.data.subscriptionId, + 'revenue': plan_price, + }) + @win.ga('send', 'event', 'checkout', 'Plan checkout') module.service("$tgAnalytics", AnalyticsService) diff --git a/gulpfile.js b/gulpfile.js index 0e7d374a..f28862f6 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -716,7 +716,7 @@ gulp.task("express", function() { res.sendFile("index.html", {root: __dirname + "/dist/"}); }); - app.listen(9001); + app.listen(9002); }); //Rerun the task when a file changes