Identifying groups
Overview
Identifying groups is similar to identifying users, the only difference is that at it identifies groups inside of your product instead of individual users.
Group identification
Developers identify groups to Dopt using the Dopt groups API. We manage your group data via upsertion i.e. we provide a single set of APIs for both creating new groups in Dopt and updating existing groups.
If you’ve used a Customer Data Platform (CDP) like Segment before, this will be familiar to you.
curl 'https://users.dopt.com/identify/group' \
-X POST \
-H 'Content-Type: application/json' \
-H 'x-api-key:$USERS_API_KEY' \
-d '{
"identifier": "123456789",
"properties": {
"name": "Acme co.",
"plan": "Pro"
}
}'
We recommend you use a unique group identifier that won’t change, such as a database ID from your organization’s internal systems.
If a group has with a name
property, it will be displayed in Dopt and be more identifiable in the Groups page.
Nested group properties are currently unsupported, but will still be accepted as valid values.
When you use the groups API in the browser the source’s write key is public because it runs in a user’s browser and can be accessed using the browser’s developer tools. You can also call identify
via the server which collects data from a server-based installation and isn’t accessible to the user.
Updating group properties
You can update group properties by using the groups API. Call the groups API with a group identifier and new or updated group properties. The group properties will be updated via upsertion: if the group property doesn’t exist, it will be created. If it does exist, it will be updated.
Initializing Dopt with a group
You can provide the group to the SDKs and APIs like this:
- React SDK
- Vue SDK
- JavaScript SDK
- Blocks API Client
<DoptProvider
flowVersions={{ [$YOUR_FLOW_ID]: $FLOW_VERSION }}
userId={$USER_ID}
groupId={$GROUP_ID}
apiKey={$BLOCKS_API_KEY}
>
...
</DoptProvider>
app.use(DoptPlugin, {
flowVersions: { [$YOUR_FLOW_ID]: $FLOW_VERSION },
userId: $USER_ID,
groupId: $GROUP_ID,
apiKey: $BLOCKS_API_KEY,
});
const dopt = new Dopt({
flowVersions: { [$YOUR_FLOW_ID]: $FLOW_VERSION },
userId: $USER_ID,
groupId: $GROUP_ID,
apiKey: $BLOCKS_API_KEY,
});
await client.flows.getFLow($YOUR_FLOW_ID, {
version: $FLOW_VERSION,
userIdentifier: $USER_ID,
groupIdentifier: $GROUP_ID,
});