Skip to content

Commit

Permalink
Update README with profile API docs
Browse files Browse the repository at this point in the history
  • Loading branch information
bmilekic committed Nov 24, 2020
1 parent 8eea95e commit 6cade0f
Showing 1 changed file with 33 additions and 3 deletions.
36 changes: 33 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ JavaScript SDK for integrating with optable-sandbox from a web site or web appli
- [Domains and Cookies](#domains-and-cookies)
- [Using (npm module)](#using-npm-module)
- [Identify API](#identify-api)
- [Profile API](#profile-api)
- [Targeting API](#targeting-api)
- [Witness API](#witness-api)
- [Using (script tag)](#using-script-tag)
Expand Down Expand Up @@ -119,6 +120,34 @@ The `identify()` method will asynchronously connect to the configured sandbox an
The frequency of invocation of `identify` is up to you, however for optimal identity resolution we recommended to call the `identify()` method on your `OptableSDK` instance on each page load while the user is authenticated, or periodically such as for example once every 15 to 60 minutes while the user is authenticated and actively using your site.

### Profile API

To associate key value traits with a user's browser, for eventual audience assembly, you can call the profile API as follows:

```javascript
const onSuccess = () => console.log("Profile API success!");
const onFailure = (err) => console.warn("Profile API error: ${err.message}");

const visitorTraits = {
gender: "M",
age: 44,
favColor: "blue",
hasAccount: true,
};

sdk.profile(visitorTraits).then(onSuccess).catch(onFailure);
```

The specified visitor traits are associated with the user's browser and can be matched during audience assembly.

Note that visitor traits are key value pairs and have type `ProfileTraits`:

```typescript
type ProfileTraits = {
[key: string]: string | number | boolean;
};
```

### Targeting API

To get the targeting key values associated by the configured sandbox with the user's browser in real-time, you can call the targeting API as follows:
Expand Down Expand Up @@ -166,19 +195,20 @@ const onFailure = (err) => console.warn("Witness API error: ${err.message}");

const eventProperties = {
property_one: "some_value",
property_two: "some other value",
property_two: 123,
property_three: false,
};

sdk.witness("event.type.here", eventProperties).then(onSuccess).catch(onFailure);
```

The specified event type and properties are associated with the logged event and which can be used for matching during audience assembly.

Note that event properties are string keyvalue pairs and have type `WitnessProperties`:
Note that event properties are key value pairs and have type `WitnessProperties`:

```typescript
type WitnessProperties = {
[key: string]: string;
[key: string]: string | number | boolean;
};
```

Expand Down

0 comments on commit 6cade0f

Please sign in to comment.