> ## Documentation Index
> Fetch the complete documentation index at: https://docs.supahub.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Add Company Data

> Enhance user context by including company data when identifying users.

<Tip>Starter or above plan is required.</Tip>

## Add company data

To further enhance the functionality and context within Supahub, you can now include company data when identifying your users. By sending company data like company name, monthly spend, pricing plan, logo etc we will track your companies, making this information accessible throughout Supahub.

Here's an example on how to add company data to an identify call:

<CodeGroup>
  ```javascript HTML theme={null}
  <script id="supahub" type="text/javascript">
    !(function (s, u, p, a) {
      function supahub() {
        var g = u.createElement(p),
          h = u.getElementsByTagName(p)[0];
        (g.id = a),
          (g.src = "https://widget.supahub.com/sdk.js"),
          h.parentNode.insertBefore(g, h);
        g.onload = function () {
          window.SupahubWidget("identify", {
            // Workspace
            workspaceName: "workspace-name", // Required: Copy your workspace name from 'workspace-name.supahub.com'

            // User Data
            id: "786", // Required: Unique id that you are using to identify your user
            name: "Username", // Required
            email: "useremail@domain.com", // Required
            avatar: "https://example.com/images/user-profile.jpg", // Optional

            customFields: {
              title: "Product Manager",
              location: "Paris",
            }, // Optional: Add any type of field, in the format ({key1: "value1", key2: "value2"})

            // Company Data
            companies: [
              {
                id: "786", // Required
                name: "Acme Inc.", // Required
                logo: "https://example.com/images/company-logo.jpg", // Optional
                monthlySpend: 300, // Optional, but recommended
                createdAt: "2023-05-19T15:35:49.915Z", // Optional
              },
            ],
          });
        };
      }
      "function" != typeof s.SupahubWidget &&
        (s.SupahubWidget = function () {
          (s.SupahubWidget.q = s.SupahubWidget.q || []).push(arguments);
        }),
        "complete" === u.readyState || "interactive" === u.readyState
          ? supahub()
          : s.addEventListener("DOMContentLoaded", supahub);
    })(window, document, "script", "supahub-sdk");
  </script>
  ```

  ```javascript Next.js theme={null}
  "use client"; // NextJS 13 requires this. Remove if you are using NextJS 12 or lower.

  import Script from "next/script";

  const YourComponent = () => {
    return (
      <>
        <Script id="supahub" strategy="afterInteractive" type="text/javascript">
          {`!(function (s, u, p, a) {
            function supahub() {var g=u.createElement(p),h=u.getElementsByTagName(p)[0];(g.id=a),(g.src="https://widget.supahub.com/sdk.js"),h.parentNode.insertBefore(g, h);
              g.onload = function () {
                window.SupahubWidget("identify", {
                  // Workspace
                  workspaceName: "workspace-name", // Required: Copy your workspace name from 'workspace-name.supahub.com'
                  
                  // User Data
                  id: "786", // Required: Unique id that you are using to identify your user
                  name: "Username", // Required
                  email: "useremail@domain.com", // Required
                  avatar: "https://example.com/images/user-profile.jpg", // Optional
                  
                  customFields: {
                      title: "Product Manager",
                  }, // Optional: Add any type of field, in the format ({key1: "value1", key2: "value2"})

                  // Company Data
                  companies: [
                      {
                          id: "786", // Required
                          name: "Acme Inc.", // Required
                          logo: "https://example.com/images/company-logo.jpg", // Optional
                          monthlySpend: 300, // Optional, but recommended
                          createdAt: "2023-05-19T15:35:49.915Z", // Optional
                      }
                  ]
                });
              }};
            "function"!=typeof s.SupahubWidget&&(s.SupahubWidget=function(){(s.SupahubWidget.q=s.SupahubWidget.q||[]).push(arguments);}),"complete"===u.readyState||"interactive"===u.readyState?supahub():s.addEventListener("DOMContentLoaded", supahub);
            })(window, document, "script", "supahub-sdk");`}
        </Script>
      </>
    );
  };

  export default YourComponent;
  ```

  ```javascript Vue.js theme={null}
  <script lang="ts" setup>
  import { onMounted } from "vue";

  onMounted(() => {
    if (document.getElementById("supahub-sdk")) {
      return;
    }

    const script = document.createElement("script");
    script.id = "supahub-sdk";
    script.src = "https://widget.supahub.com/sdk.js";
    script.async = true;
    script.onload = () => {
      const win: any = window;
      win.SupahubWidget("identify", {
        // Workspace
        workspaceName: "workspace-name", // Required: Copy your workspace name from 'workspace-name.supahub.com'

        // User Data
        id: "786", // Required: Unique id that you are using to identify your user
        name: "Username", // Required
        email: "useremail@domain.com", // Required
        avatar: "https://example.com/images/user-profile.jpg", // Optional

        customFields: {
          title: "Product Manager",
        }, // Optional: Add any type of field, in the format ({key1: "value1", key2: "value2"})

        // Company Data
        companies: [
          {
            id: "786", // Required
            name: "Acme Inc.", // Required
            logo: "https://example.com/images/company-logo.jpg", // Optional
            monthlySpend: 300, // Optional, but recommended
            createdAt: "2023-05-19T15:35:49.915Z", // Optional
          },
        ],
      });
    };

    document.head.appendChild(script);
  });
  </script>

  <template>
    <h1>This is a component</h1>
  </template>

  <style>
  ...
  </style>
  ```
</CodeGroup>

<Tip>
  For improved sorting capabilities, we strongly recommend including the
  `monthlySpend` for each company.
</Tip>

This helps you to prioritize and identify the most requested posts by your paying users, ensuring that you address their needs effectively.

In situations where users manage multiple companies, add each company to the `companies` array in the identify call.

## Add custom fields for a company

You can enhance the information associated with your companies by adding custom fields, such as their chosen pricing plan, employees, industry, and more.

To add custom data for a company to an identify call, follow this example:

<CodeGroup>
  ```javascript HTML theme={null}
  <script id="supahub" type="text/javascript">
    !(function (s, u, p, a) {
      function supahub() {
        var g = u.createElement(p),
          h = u.getElementsByTagName(p)[0];
        (g.id = a),
          (g.src = "https://widget.supahub.com/sdk.js"),
          h.parentNode.insertBefore(g, h);
        g.onload = function () {
          window.SupahubWidget("identify", {
            // Workspace
            workspaceName: "workspace-name", // Required: Copy your workspace name from 'workspace-name.supahub.com'

            // User Data
            id: "786", // Required: Unique id that you are using to identify your user
            name: "Username", // Required
            email: "useremail@domain.com", // Required
            avatar: "https://example.com/images/user-profile.jpg", // Optional

            customFields: {
              title: "Product Manager",
              location: "Paris",
            }, // Optional: Add any type of field, in the format ({key1: "value1", key2: "value2"})

            // Company Data
            companies: [
              {
                id: "786", // Required
                name: "Acme Inc.", // Required
                logo: "https://example.com/images/company-logo.jpg", // Optional
                monthlySpend: 300, // Optional, but recommended
                createdAt: "2023-05-19T15:35:49.915Z", // Optional

                customFields: {
                  plan: "Premium",
                  employees: 100,
                  industry: "technology",
                }, // Optional: Add any type of field, in the format ({key1: "value1", key2: "value2"})
              },
            ],
          });
        };
      }
      "function" != typeof s.SupahubWidget &&
        (s.SupahubWidget = function () {
          (s.SupahubWidget.q = s.SupahubWidget.q || []).push(arguments);
        }),
        "complete" === u.readyState || "interactive" === u.readyState
          ? supahub()
          : s.addEventListener("DOMContentLoaded", supahub);
    })(window, document, "script", "supahub-sdk");
  </script>
  ```

  ```javascript Next.js theme={null}
  "use client"; // NextJS 13 requires this. Remove if you are using NextJS 12 or lower.

  import Script from "next/script";

  const YourComponent = () => {
    return (
      <>
        <Script id="supahub" strategy="afterInteractive" type="text/javascript">
          {`!(function (s, u, p, a) {
            function supahub() {var g=u.createElement(p),h=u.getElementsByTagName(p)[0];(g.id=a),(g.src="https://widget.supahub.com/sdk.js"),h.parentNode.insertBefore(g, h);
              g.onload = function () {
                window.SupahubWidget("identify", {
                  // Workspace
                  workspaceName: "workspace-name", // Required: Copy your workspace name from 'workspace-name.supahub.com'
                  
                  // User Data
                  id: "786", // Required: Unique id that you are using to identify your user
                  name: "Username", // Required
                  email: "useremail@domain.com", // Required
                  avatar: "https://example.com/images/user-profile.jpg", // Optional
                  
                  customFields: {
                      title: "Product Manager",
                      location: "Paris",
                  }, // Optional: Add any type of field, in the format ({key1: "value1", key2: "value2"})

                  // Company Data
                  companies: [
                    {
                      id: "786", // Required
                      name: "Acme Inc.", // Required
                      logo: "https://example.com/images/company-logo.jpg", // Optional
                      monthlySpend: 300, // Optional, but recommended
                      createdAt: "2023-05-19T15:35:49.915Z", // Optional

                      customFields: {
                          plan: "Premium",
                          employees: 100,
                          industry: 'technology',
                      } // Optional: Add any type of field, in the format ({key1: "value1", key2: "value2"})
                    }
                  ]
                });
              }};
            "function"!=typeof s.SupahubWidget&&(s.SupahubWidget=function(){(s.SupahubWidget.q=s.SupahubWidget.q||[]).push(arguments);}),"complete"===u.readyState||"interactive"===u.readyState?supahub():s.addEventListener("DOMContentLoaded", supahub);
            })(window, document, "script", "supahub-sdk");`}
        </Script>
      </>
    );
  };

  export default YourComponent;
  ```

  ```javascript Vue.js theme={null}
  <script lang="ts" setup>
  import { onMounted } from "vue";

  onMounted(() => {
    if (document.getElementById("supahub-sdk")) {
      return;
    }

    const script = document.createElement("script");
    script.id = "supahub-sdk";
    script.src = "https://widget.supahub.com/sdk.js";
    script.async = true;
    script.onload = () => {
      const win: any = window;
      win.SupahubWidget("identify", {
        // Workspace
        workspaceName: "workspace-name", // Required: Copy your workspace name from 'workspace-name.supahub.com'

        // User Data
        id: "786", // Required: Unique id that you are using to identify your user
        name: "Username", // Required
        email: "useremail@domain.com", // Required
        avatar: "https://example.com/images/user-profile.jpg", // Optional

        customFields: {
          title: "Product Manager",
          location: "Paris",
        }, // Optional: Add any type of field, in the format ({key1: "value1", key2: "value2"})

        // Company Data
        companies: [
          {
            id: "786", // Required
            name: "Acme Inc.", // Required
            logo: "https://example.com/images/company-logo.jpg", // Optional
            monthlySpend: 300, // Optional, but recommended
            createdAt: "2023-05-19T15:35:49.915Z", // Optional

            customFields: {
              plan: "Premium",
              employees: 100,
              industry: "technology",
            }, // Optional: Add any type of field, in the format ({key1: "value1", key2: "value2"})
          },
        ],
      });
    };

    document.head.appendChild(script);
  });
  </script>

  <template>
    <h1>This is a component</h1>
  </template>

  <style>
  ...
  </style>
  ```
</CodeGroup>

By incorporating custom fields, you can gain deeper insights and tailor your analysis in Supahub based on your specific requirements.
