mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-04-30 16:03:37 -04:00
Add revenue tracking to analytics
This commit is contained in:
parent
c6502f5dab
commit
8df3eed824
3 changed files with 8 additions and 1 deletions
app
|
@ -128,6 +128,7 @@ module.exports = class User extends CocoModel
|
||||||
|
|
||||||
getGemPromptGroup: ->
|
getGemPromptGroup: ->
|
||||||
# A/B Testing whether extra prompt when low gems leads to more gem purchases
|
# A/B Testing whether extra prompt when low gems leads to more gem purchases
|
||||||
|
# TODO: Rename gem purchase event in BuyGemsModal to 'Started gem purchase' after this test is over
|
||||||
return @gemPromptGroup if @gemPromptGroup
|
return @gemPromptGroup if @gemPromptGroup
|
||||||
group = me.get('testGroupNumber') % 8
|
group = me.get('testGroupNumber') % 8
|
||||||
@gemPromptGroup = switch group
|
@gemPromptGroup = switch group
|
||||||
|
|
|
@ -57,6 +57,7 @@ module.exports = class BuyGemsModal extends ModalView
|
||||||
Backbone.Mediator.publish 'buy-gems-modal:purchase-initiated', { productID: productID }
|
Backbone.Mediator.publish 'buy-gems-modal:purchase-initiated', { productID: productID }
|
||||||
|
|
||||||
else
|
else
|
||||||
|
# TODO: rename this event to 'Started gem purchase' after gemPrompt A/B test is over
|
||||||
application.tracker?.trackEvent 'Started purchase', { productID: productID }
|
application.tracker?.trackEvent 'Started purchase', { productID: productID }
|
||||||
stripeHandler.open({
|
stripeHandler.open({
|
||||||
description: $.t(product.i18n)
|
description: $.t(product.i18n)
|
||||||
|
@ -78,6 +79,9 @@ module.exports = class BuyGemsModal extends ModalView
|
||||||
@render()
|
@render()
|
||||||
jqxhr = $.post('/db/payment', data)
|
jqxhr = $.post('/db/payment', data)
|
||||||
jqxhr.done(=>
|
jqxhr.done(=>
|
||||||
|
application.tracker?.trackEvent 'Finished gem purchase',
|
||||||
|
productID: @productBeingPurchased.id
|
||||||
|
revenue: @productBeingPurchased.amount / 100
|
||||||
document.location.reload()
|
document.location.reload()
|
||||||
)
|
)
|
||||||
jqxhr.fail(=>
|
jqxhr.fail(=>
|
||||||
|
|
|
@ -72,6 +72,8 @@ module.exports = class SubscribeModal extends ModalView
|
||||||
amount: 599
|
amount: 599
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@purchasedAmount = options.amount
|
||||||
|
|
||||||
stripeHandler.open(options)
|
stripeHandler.open(options)
|
||||||
|
|
||||||
onStripeReceivedToken: (e) ->
|
onStripeReceivedToken: (e) ->
|
||||||
|
@ -88,7 +90,7 @@ module.exports = class SubscribeModal extends ModalView
|
||||||
me.patch({headers: {'X-Change-Plan': 'true'}})
|
me.patch({headers: {'X-Change-Plan': 'true'}})
|
||||||
|
|
||||||
onSubscriptionSuccess: ->
|
onSubscriptionSuccess: ->
|
||||||
application.tracker?.trackEvent 'Finished subscription purchase', {}
|
application.tracker?.trackEvent 'Finished subscription purchase', revenue: @purchasedAmount / 100
|
||||||
application.tracker?.trackPageView "subscription/finish-purchase", ['Google Analytics']
|
application.tracker?.trackPageView "subscription/finish-purchase", ['Google Analytics']
|
||||||
Backbone.Mediator.publish 'subscribe-modal:subscribed', {}
|
Backbone.Mediator.publish 'subscribe-modal:subscribed', {}
|
||||||
@playSound 'victory'
|
@playSound 'victory'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue