Associations

Stacksync support syncing your HubSpot Associations in real-time πŸš€

TL;DR

  • Stacksync supports two-way sync for HubSpot associations πŸŽ‰

  • Associations are undirected, meaning that if object A is associated with object B, object B is also associated with object A in return.

  • Associations cannot be updated, but you can delete and create a new one.

  • You can add several associations (with different association labels) to the same pair of objects.

  • Associations between ALL synced objects are supported, including emails, meetings, engagements, all standard and custom objects...

  • Associations for custom objects are also supported βœ…

How HubSpot associations work

To associate two objects in HubSpot, you need to sync and use a third table "the association table" which contains in each row both of the object_ids to associate (e.g. associating a contact_id and a company_id).

When you connect two objects in HubSpot, the connection is undirected. If Contact A is connected to Company X, then Company X is also connected to Contact A in return.

To specify the type of connection between two objects, you can utilize association labels. For instance, Contact A can be labeled as a manager at Company X and also as a director at Company Y. In this case, you would connect Contact A with both companies but assign different labels to each connection.

Example of HubSpot associations: the same Contact is associated with two different Companies, each with different roles.

You can add several labels to the same pair of objects. For instance, Contact A can be in the finance_department and in the marketing_department of the same company. For that, you can add two rows for the same pair of objects but with different association labels as follows:

Stacksync ensures that all associations between pairs of object types are synchronized to an associative table. For example, any connection between a Contact and a Company will be synced to the "associations_company_and_contact" table, which has the following 3 columns:

  • contact_id (string)

  • company_id (string)

  • association_label (string)

There will be an additional column stacksync_record_id_xxxxxx. Don't worry, this column is just used by Stacksync to keep your records syncing properly. Just do not tamper this column!

Because HubSpot associations are undirected, these associations will only appear in one table. If you have a table associations_company_and_contact, there won't be a table with the opposite order (associations_contact_and_company).

Associations cannot be updated. Instead, you can delete and then create an association between the two desired objects with a different label.

Association Labels

HubSpot provides a set of predefined association types (e.g. unlabeled contact to company), but users can define custom association labels, if it is included in their HubSpot plan. There are two HubSpot-defined association types:

  • No Label (Default Association Type)

    • Every association between objects (Contacts, Companies, Deals, etc.) automatically has a default unlabeled association.

    • Even when a labeled association is added (Primary or Custom), the unlabeled association remains.

  • 'Primary' Label (For Company-Contact Associations)

    • HubSpot has a built-in 'Primary' label specifically for associating a Contact with their main Company.

    • While a Contact must have a primary company, other objects (e.g., Deals) may or may not have a primary company.

    • Example: Joe works at both Google and Amazon, but Google is his primary employer.

  • Custom Labels

    • Users on eligible HubSpot plans can define custom association labels (e.g., β€˜Advisor’ for a Contact-Company relationship), you can define through the Hubspot UI or .e Hubspot API.

    • When a custom label is added, the default unlabeled association still exists.

    • Example: Tom is an Advisor at Amazon, so a custom label 'Advisor' is created for his Contact-Company association besides the default unlabeled association.

Read more on the HubSpot Association documentation here.

Querying your data

You can JOIN your data using the associations tables as follows:

SELECT
  -- Contact data
  contact.id, contact.email,
  -- Company data
  company.id, company.city,
  -- Association label
  associations.association_label
FROM (SELECT DISTINCT company_id, contact_id FROM hubspot.associations_company_and_contact) associations
LEFT JOIN hubspot.company company ON company.id = association.company_id
LEFT JOIN hubspot.contact contact ON contact.id = association.contact_id;

In this particular example, Contact and Company are used, but the principles mentioned can be applied to any other HubSpot CRM objects that can be synced with Stacksync. Suppose you have the custom Pets and custom Shelters objects in HubSpot. In that case, Stacksync will synchronize an associations_pets_and_shelters table, including the pet_id and shelter_id columns.

Last updated