Last active
August 29, 2015 14:03
-
-
Save gooley/efbb809a83394932afea to your computer and use it in GitHub Desktop.
Preact+Segment Server-Side Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# @current_user is your logged-in user object | |
# @current_account is your account object | |
Analytics.track( | |
user_id: @current_user.id.to_s, | |
event: name, | |
properties: { | |
account: { | |
name: @current_account.name, | |
id: @current_account.id.to_s, | |
license_mrr: @current_account.monthly_rate.to_i, # optional | |
license_status: @current_account.status # optional | |
} | |
}, | |
context: { | |
traits: { | |
email: @current_user.email, | |
name: @current_user.name, | |
created_at: @current_user.created_at.to_i | |
} | |
}) | |
# example with hard-coded values | |
Analytics.track( | |
user_id: "123", | |
event: "deleted-thing", | |
properties: { | |
account: { | |
id: "55534", | |
name: "Preact", | |
license_status: "paying", # optional | |
license_mrr: 499 # optional | |
} | |
}, | |
context: { | |
traits: { | |
email: "[email protected]", | |
name: "Christopher Gooley", | |
created_at: 383904000 | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks. That's useful. I suggest posting it on your website because it would definitely save your future customers a lot of development time.