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 that they are a part of.

For example, if you’re an API provider, users may the be the individual employees name, email, and employment title creating API token and calling your API while companies can track the organization name and monthly revenue. Whereas if your API is used by partners, then you can use the partner company as the company in Moesif.

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-express 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, but it’s much more useful if you enrich with your own metadata such as company name, subscription or plan revenue, number of employees or any other metadata you want to store in Moesif.

In order to add company metadata to Moesif, just call the SDK’s updateCompany() method such as the moesif-express 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. That is, the same company_id will be linked to many session_token’s. This can aid you in seeing how many API tokens a specific company is currently using 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. Instead of overriting 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 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 same rules that apply to user metadata also apply to company metadata.

1. Maintain consistent datatypes

Once a JSON key is seen by Moesif with a specific JSON datatype, 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. Hoever, 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"
}

Updated: