@attraqt/activity
v2.0.0
Published
## Installation and Usage
Downloads
3,892
Readme
@attraqt/activity
Installation and Usage
npm install --save @attraqt/activity
import {activity} from @attraqt/activity
activity.init({
trackerKey: "YOUR_TRACKER_KEY",
region: "WEBSITE_REGION" // optional, set to EU by default
});
activity.setUser({
identities: {
sessionid: "YOUR_SESSION_ID"
},
traits: {
birthday: "2020-04-01"
},
segments: ["segment1"]
});
activity.send({
action: "view",
target: {
product: "YOUR_PRODUCT_ID"
}
});
Methods
| Method | Argument(s) | Result | Description |
| ----------------- | ---------------------------------------------------------------------------------------------------------------- | ------------------- | ----------------------------------------------------- |
| 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 |