@attraqt/activity
Installation and Usage
npm install --save @attraqt/activity
import {activity} from @attraqt/activity
activity.init({
trackerKey: "YOUR_TRACKER_KEY",
region: "WEBSITE_REGION"
});
activity.setUser({
identities: {
sessionid: "YOUR_SESSION_ID"
},
traits: {
birthday: "2020-04-01"
},
segments: ["segment1"]
});
activity.send({
action: "view",
target: {
product: "YOUR_PRODUCT_ID"
}
});
Methods
init | options: ActivityInitOptions | void | Initializes the activity client |
send | activity: Activity | Activity[] , options?: SendActivityOptions | Promise<Response> | Sends the activity |
setUser | user: User | void | Sets the user to be sent along with future activities |
clearUser | | void | Clears the previously set user |
addUserIdentity | identityRepository: string , identity: string | void | Sets a user identity |
setUserIdentities | identities: {[identityRepository: string]: string} | void | Sets user identities |
addUserSegment | segment: string | void | Adds a segment to the user |
setUserSegments | segments: string[] | void | Sets user segments |
addUserTrait | trait: string , traitValue: string | void | Adds a trait to the user |
setUserTraits | traits: {[trait: string]: string} | void | Sets user traits |
getUserClusters | | Promise< Clusters> | get the user clusters |