[backport] Fixed checkout monitoring in analytics

stable
Jesús Espino 2017-10-31 10:53:04 +01:00
parent 4fd3ae5e74
commit 0bcc559226
1 changed files with 13 additions and 18 deletions

View File

@ -85,22 +85,6 @@ class AnalyticsService extends taiga.Service
@win.ga("send", "event", category, action, label, value) @win.ga("send", "event", category, action, label, value)
ecStep: (step) ->
return if not @.initialized
return if not @win.ga
if step == "register"
stepId = 1
else if step == "change-plan"
stepId = 2
else if step == "select-plan"
stepId = 3
else if step == "confirm-plan"
stepId = 4
else if step == "plan-changed"
stepId = 5
ecViewPlan: (plan) -> ecViewPlan: (plan) ->
return if not @.initialized return if not @.initialized
return if not @win.ga return if not @win.ga
@ -171,13 +155,24 @@ class AnalyticsService extends taiga.Service
'quantity': 1, 'quantity': 1,
'position': 1, 'position': 1,
}) })
@.ecStep("confirm-plan") @win.ga('ec:setAction','checkout', {'step': 1,})
@.trackEvent("ecommerce", "start-checkout", step, stepId)
ecPurchase: (plan_id, plan_name, plan_price) -> ecPurchase: (plan_id, plan_name, plan_price) ->
return if not @.initialized return if not @.initialized
return if not @win.ga return if not @win.ga
@.ecStep("plan-changed") @win.ga('ec:addProduct', {
'id': plan_id,
'name': plan_name,
'price': plan_price,
'category': "plans",
'quantity': 1,
'position': 1,
})
@win.ga('ec:setAction','checkout', {'step': 2,})
@.trackEvent("ecommerce", "start-checkout", step, stepId)
@win.ga('ec:addProduct', { @win.ga('ec:addProduct', {
'id': plan_id, 'id': plan_id,