The useGroup() hook enables you to add properties and send tracking events to the current group.

About this hook

The hook contains the following methods:

track(eventName: string, properties?: Record<string, unknown>)
Promise that sends tracking events for the current group
addProperties(properties: Record<string, unknown>)
Promise that adds properties to the current group
setGroupId(groupId: string, properties?: Record<string, unknown>)
Promise that sets the current group ID. Using this hook can cause unexpected behaviors if also setting the group ID at the <Frigade.Provider /> level.

Example use cases:

  • Tracking events and adding properties to the current group for using with Targeting
  • Wrapping the track method with your existing tracking/analytics methods

Example usage:

import { useGroup } from '@frigade/react';

function MyComponent() {
  const { addProperties } = useGroup();

  return (
    <button
      onClick={() => {
        addProperties({ orgHasConnectedBankAccount: true });
      }}
    >
      Connect Bank Account
    </button>
  );
}
Make sure to call any Frigade hook within the context of <Frigade.Provider />

Standardized properties

The following standardized properties are automatically added to the group object if provided via addProperties:

  • name: The name of the group/company/organiation
  • imageUrl: The URL of the group/company/organiation’s logo