Skip to content

Instantly share code, notes, and snippets.

@astfarias
astfarias / aidax-syntax-Session.js
Created August 10, 2017 17:23
AIDAX - Syntax - User
// Session properties
// client-side JS
ax.session({
property1: "value",
property2: "value"
});
// server-side HTTP request
curl https://api.aidax.com.br/session?key=<key>&uid=<user id>&origin=<optional session origin>&p=<session properties in JSON format>
@astfarias
astfarias / aidax-example-query-profile.js
Last active August 4, 2017 05:23
AIDAX - Query Execution Example Using JS Client to Query Current User Profile on Backend
// Check if user belongs to profile that likes red fruits
// client JS
ax.query({
type: "profile", // user, session, profile, event or metric
value: "red_fruits", //required for profile and event
callback: function(data) {
// returns true or false
}
});
@astfarias
astfarias / aidax-example-identifyUser-tags.js
Last active August 4, 2017 22:02
AIDAX - User id during session with additional properties - multiple tags
// Adding Properties at Run Time
// client-side JS
ax.user({
id: "lucas@email.com.br",
properties: {
age: "25",
gender: "M",
$tags: ["drink", "red fruit", "pasta"]
}
});
@astfarias
astfarias / aidax-example-identifyUser-import_properties.js
Last active August 4, 2017 05:24
AIDAX - User ID in session and import of previously captured properties
// Identification of João in session WITHOUT import previously captured properties
// client-side JS
ax.user({ id: "joao@email.com", migrate: false });
// server-side HTTP request
curl https://api.aidax.com.br/user?key=<key>&uid="joao@email.com"
// Identification of João in the session WITH import previously captured properties
// client-side JS
@astfarias
astfarias / aidax-example-identifyUser-joao.js
Last active August 4, 2017 05:15
AIDAX - Capturing user id during session with no additional properties
// Identification of João in the session
// client-side JS
ax.user({ id: "joao@email.com" });
// server-side HTTP request
curl https://api.aidax.com.br/user?key=<key>&uid="joao@email.com"
@astfarias
astfarias / aidax-example-identifyUser-add-subscribe_newsletter.js
Last active August 4, 2017 05:18
AIDAX - Capturing User with Adding Subscription Subscription Property
// Adding Unique Properties of Joo in Session
// client-side JS
ax.user({
id: "joao@email.com",
properties: {
has_cleancode_newsletter: true, //turn subscription on or off
cleancode_newsletter_email: "joaodev@emaildev.com", //If the emails are different in the subscription
$tags: ["cleancode_newsletter_teste", "cleancode_newsletter_JS"] //newsletter preferences
}
});
@astfarias
astfarias / aidax-example-identifyUser-add_properties.js
Last active August 4, 2017 05:22
AIDAX - Adding Unique Properties of John in session without id
// Adding John Properties at run time without id
// client-side JS
ax.user({
properties: {
age: "25",
job: "Data Analyst",
$tags: ["beer"]
}
});
@astfarias
astfarias / aidax-syntax-User.js
Last active August 10, 2017 17:24
AIDAX - Syntax - User
// Identify User
// client-side JS
ax.user({
id: "USER ID", //If the id is an email AIDAX will contextalize the id
properties: {
property1: "value",
property2: "value"
},
migrate: true //optional parameter to migrate old user data in this session to the new user. Default is true
});