Identify
Tie anonymous activity to a CRM contact, before or after they have an account.
Until you identify someone, Saasco knows a visitor id and a session id and nothing else. identify() connects that activity to a CRM contact, which is what makes drip campaigns, segments and support history work.
import { saasco } from "../lib/saasco";
function signedIn(user) {
saasco.identify(user.id, {
name: "Tony Hawk",
email: "tony@xgames.com",
bestTrick: 900,
});
}
function signedOut() {
saasco.logout();
}The first argument is a Distinct ID, normally the user's primary key in your own database. The second is any properties you want on the contact.
Call identify when someone logs in or their details change, not on every
page load. Repeat calls with the same id and the same traits are skipped, but
the first one of each page still costs a request.
The same call is mirrored into the support widget, so the agent knows who it's talking to. That forwarding isn't gated by the dashboard toggle; the toggle only decides whether the widget loader downloads. If you load the standalone support loader without the analytics SDK, call window.SaascoSupport.identify(...) yourself.
People without an account yet
You often have contact details before there's a user record: a newsletter subscribe, a waitlist, step one of a signup flow. Skip the id and pass properties only:
saasco.identify({
name: "Tony Hawk",
email: "tony@xgames.com",
bestTrick: 900,
});Include an email. That is what makes the contact useful to email marketing, and what lets Saasco merge it later.
Soft vs full identify
Identifying without an id is a soft identify: the SDK mints a soft_* distinct id and creates a real CRM contact against it. When that person later signs up and you identify them with your database id and the same email, the soft contact is merged into the full one and their earlier activity comes with it.
Both kinds create a contact. The CRM does not label them "lead" versus "customer" on this basis; that's for you to model with properties or lists.
Signing out
saasco.logout();logout() clears the user cookie, mints a fresh session and anonymous id, clears the support widget's identity, and drops last-touch UTM and referrer so the next visitor on a shared machine starts clean.
It is the sign-out helper you want. identify(null) does most of the same work but keeps last-touch attribution, and does not POST an identify event.
Reserved contact properties
These property names have meaning to the rest of the product: email marketing reads email, and the CRM header reads name and avatar. Use the exact keys:
| Property | Type | Description |
|---|---|---|
email | String | Email address. Required for anything that sends mail. |
name | String | Full name. |
firstName | String | First name. |
lastName | String | Last name. |
displayName | String | Preferred display name; defaults to firstName lastName. |
title | String | Job title (e.g. "VP of Engineering"). |
phone | String | Phone number. |
avatar | String | URL to an avatar image. |
username | String | Username; should be unique per user. |
website | String | Personal or company website. |
description | String | Bio or about text. |
gender | String | Gender. |
age | Number | Age. |
birthday | Date | Date of birth. |
createdAt | Date | When the account was created. ISO 8601 strings are recommended. |
Anything else you pass is stored as a custom attribute and is filterable in the CRM the same way.
Keys beginning with $ are system-managed, so don't set them. See Properties for what Saasco fills in on its own.