Company Profiles
Moesif can track companies, not just individual users. If your customers are other businesses, you may want to track the individual users calling using your API separately from the organizations they are a part of.
For example, suppose you’re an API provider. In that case, users may be the individual employees’ name, email, and employment title, creating API tokens and calling your API. At the same time, companies can track the organization’s name and monthly revenue. If partners use your API, then you can use the partner company as the company in Moesif.
A company profile and the fields shown can be customized. To see exactly how to do this, check out the docs on Profile View.
You can associate API calls to both user and a company, or just one of the two. For example, maybe you don’t have user information, so you can only associate API Calls with companies, or you’re B2C, so it makes sense to track only users.
You can enrich companies with company data in your CRM or other tools.
What are company properties?
Companies can track arbitrary properties such as company name, industry sector, revenue or plan information, or domain name.
How to track companies
1. Set the identifyCompany function
By defining an identifyCompany
callback such as setting the moesif-nodejs identifyCompany() option, you ensure new API calls are associated with a specific company_id.
2. Enrich the company with additional metadata
If you only did Step 1, you’ll see some company analytics in Moesif like first and last seen time. Still, it’s much more useful if you enrich your own metadata such as company name, subscription or plan revenue, number of employees, or any other metadata you want to store in Moesif.
To add company metadata to Moesif, call the SDK’s updateCompany()
method, such as the moesif-nodejs updateCompany() method from your code with the company_id
and JSON metadata you want to store. You only need to call this when your own company data changes, such as when the customer changes their subscription.
How to alias a session
Multiple sessions tokens can be associated with the same company. For example, the same company_id
can be linked to many session_token
’s. This can aid you in seeing how many API tokens a specific company uses or how often.
To create a new link or alias, call the update company API with at least the company_id and session_token set. Then, instead of overwriting the session_token, Moesif will append it with the existing company’s alias table.
Companies metadata
You can save any custom metadata with a company, such as the company’s name, total revenue, or the number of employees. You can search and filter by companies in the Moesif portal via the metadata. The metadata must be a valid JSON object.
{
"company_name": "Acme, Inc",
"company_domain": "www.acmeinc.com",
"mrr": 5000,
"is_paid": true,
"num_employees": 100000,
"custom_int_field": 55,
"custom_obj_field": {
"sub_a": "value_a",
"sub_b": "value_b"
}
}
The user metadata can be views in Moesif under a user’s profile. Viewing the metadata can be done by going to a user profile, clicking the More Actions button, and selecting Show JSON Data.
The data will then be displayed in a modal to view.
The same rules that apply to user metadata also apply to company metadata.
1. Maintain consistent data-types
Once a JSON key is seen by Moesif with a specific JSON data type, you cannot send a different JSON datatype using the same key. For example, if you previously sent to Moesif the following custom metadata for an API call:
{
"company_name": "Acme, Inc",
"company_domain": "www.acmeinc.com",
"phone": "123-456-7890"
}
Then, Moesif automatically saves phone
as a JSON string in the metadata schema. You cannot later send a JSON Number using the same phone
key. This is true regardless of the number of levels relative to the object root. The below metadata would now be invalid:
{
"company_name": "Acme, Inc",
"company_domain": "www.acmeinc.com",
"additional_info": {
"phone": 1234567890
}
}
The metadata schema is shared across your organization and applications.
2. Avoid dots characters
Be aware that Dot characters in a JSON key for custom metadata will be converted into an underscore by Moesif automatically. However, Dot characters in a JSON value are fine and will not be transformed.
For example,
{
"comp.any.na.me": "Acme, Inc"
}
Will be converted by Moesif to:
{
"comp_any_na_me": "John Doe"
}