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
def update_ducksboard | |
api_key = "" | |
api_secret = "" | |
url = "https://#{api_key}:#{api_secret}@api.preact.io/api/v2/insights/health" | |
data = RestClient.get "#{url}", :content_type => :json, :accept => :json | |
accounts = data["accounts"] | |
# boxes | |
push_duck("YOUR_DATAPOINT_ID", accounts["good"]) # good account health |
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, |
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.identify(current_user.id, { | |
email : current_user.email, | |
name : current_user.name | |
}); | |
analytics.group(current_account.id, { | |
name: current_account.name, |
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
// User Event | |
{ | |
"person": { | |
"email": "[email protected]", | |
"name": "Christopher Gooley", | |
"created_at": 1404329291.5481384, | |
"uid": "383838211" | |
} | |
"event": { |
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
<script type="text/javascript"> | |
var _preactq = _preactq || [] | |
_preactq.push(['_setCode', #{ Preact.configuration.code.to_json }]); | |
_preactq.push(['_setPersonData', #{ @current_user.to_preact.to_json }]); | |
_preactq.push(['_setAccount', #{ @current_project.to_preact.to_json }]); // TODO: replace @current_project with variable for the "account" model | |
(function() { | |
var preact = document.createElement('script'); preact.type = 'text/javascript'; preact.async = true; | |
preact.src = 'https://s3.amazonaws.com/lessneglect-cdn-01/js/preact-4.0.js'; | |
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(preact, s); |
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
<script type="text/javascript"> | |
var _preactq = _preactq || [] | |
_preactq.push(['_setCode', <%= Preact.configuration.code.to_json %>); | |
_preactq.push(['_setPersonData', <%= @current_user.to_preact.to_json %>]); | |
_preactq.push(['_setAccount', <%= @current_project.to_preact.to_json %>]); // TODO: replace @current_project with variable for the "account" model | |
(function() { | |
var preact = document.createElement('script'); preact.type = 'text/javascript'; preact.async = true; | |
preact.src = 'https://s3.amazonaws.com/lessneglect-cdn-01/js/preact-4.0.js'; |
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
<script type="text/javascript"> | |
var _preactq = _preactq || [] | |
// TODO: put your preact project code here | |
_preactq.push(['_setCode', 'your-code-1234' ]); | |
// TODO: insert the info for the currently logged-in user | |
_preactq.push(['_setPersonData', { email: '[email protected]', name: 'John Doe', created_at: 1410817680 } ]); | |
// TODO: insert the account info for the currently logged-in user | |
_preactq.push(['_setAccount', { id: '12334', name: 'Doe Flower Shop' }]); | |
(function() { |
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
// document head | |
// Put this script block inside the template for your document head, it will load and initialize the Preact logging javascript | |
<script> | |
window._preactq = window._preactq || []; | |
window._preactq.push(['_setCode', 'your_project_code']); | |
$(function(){ | |
if(HelpCenter.user){ | |
window._preactq.push(['_setPersonData', { | |
name: HelpCenter.user.name, |
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
private static void LogAction(string username, string action, string item = "None", Segmentio.Model.Properties properties = null) | |
{ | |
// Segment.IO Properties | |
if (properties == null) | |
{ | |
properties = new Segmentio.Model.Properties(); | |
} | |
properties.Add("ProductName", "Example WebApp"); | |
properties.Add("URL", "http://www.example.com"); |
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
// A standard mixpanel track event takes a name and optional Properties | |
mixpanel.track("Viewed Dashboard", {"Gender": "Male", "Age": 21}); | |
// Pass account context information along with each Track call using the following properties | |
{ | |
"_account_id": "333434", // this should be your internal id for the account | |
"_account_name": "Snapchat" // this should be a display name for the account | |
} | |
// pass those properties (along with any others you already pass) with each track call |