Add tracking for FB and G+ signups

This commit is contained in:
Matt Lott 2014-12-08 15:00:49 -08:00
parent b69bdfd360
commit a21a2f7c8f
3 changed files with 13 additions and 6 deletions

View file

@ -42,12 +42,16 @@ module.exports = FacebookHandler = class FacebookHandler extends CocoClass
me.set('facebookID', r.id) if r.id
Backbone.Mediator.publish 'auth:logging-in-with-facebook', {}
window.tracker?.trackEvent 'Facebook Login'
window.tracker?.identify()
beforeID = me.id
me.patch({
error: backboneFailure,
url: "/db/user/#{me.id}?facebookID=#{r.id}&facebookAccessToken=#{@authResponse.accessToken}"
success: (model) ->
window.tracker?.trackEvent 'Facebook Login', category: "Signup", ['Google Analytics']
if model.id is beforeID
window.tracker?.trackEvent 'Finished Signup', category: "Signup", label: 'Facebook'
window.tracker?.trackPageView "signup/finished", ['Google Analytics']
window.location.reload() if model.get('email') isnt oldEmail
})

View file

@ -98,11 +98,10 @@ module.exports = GPlusHandler = class GPlusHandler extends CocoClass
Backbone.Mediator.publish 'auth:logging-in-with-gplus', {}
gplusID = me.get('gplusID')
window.tracker?.trackEvent 'Google Login'
window.tracker?.identify()
patch = {}
patch[key] = me.get(key) for gplusKey, key of userPropsToSave
patch._id = me.id
patch._id = beforeID = me.id
patch.email = me.get('email')
wasAnonymous = me.get('anonymous')
@trigger 'logging-into-codecombat'
@ -111,11 +110,15 @@ module.exports = GPlusHandler = class GPlusHandler extends CocoClass
patch: true
type: 'PUT'
error: ->
console.debug('Logging into GPlus fail.', arguments)
console.warn('Logging into GPlus fail.', arguments)
backboneFailure(arguments...)
url: "/db/user?gplusID=#{gplusID}&gplusAccessToken=#{@accessToken.access_token}"
success: (model) ->
console.debug('GPLus login success!')
console.info('GPLus login success!')
window.tracker?.trackEvent 'Google Login', category: "Signup", ['Google Analytics']
if model.id is beforeID
window.tracker?.trackEvent 'Finished Signup', label: 'GPlus'
window.tracker?.trackPageView "signup/finished", ['Google Analytics']
window.location.reload() if wasAnonymous and not model.get('anonymous')
})

View file

@ -90,7 +90,7 @@ module.exports = class AuthModal extends ModalView
res = tv4.validateMultiple userObject, User.schema
return forms.applyErrorsToForm(@$el, res.errors) unless res.valid
Backbone.Mediator.publish "auth:signed-up", {}
window.tracker?.trackEvent 'Finished Signup'
window.tracker?.trackEvent 'Finished Signup', label: 'CodeCombat'
window.tracker?.trackPageView "signup/finished", ['Google Analytics']
@enableModalInProgress(@$el)
createUser userObject, null, window.nextLevelURL