Drupal is a registered trademark of Dries Buytaert

hubspot_client

14 sites Security covered
View on drupal.org

This module provides a client for the HubSpot API v3 SDK. It is intended to be used by other modules to integrate with HubSpot.
Recommended usage:

  • Install and enable the module and submodules you need - see details below -, then go to /admin/config/system/hubspot-sync
  • Sync HubSpot IDs to Drupal if you want to map existing Hubspot objects with Drupal.
  • Sync Drupal data to HubSpot to populate and update HubSpot objects.
  • Keep the module enabled so that it can keep HubSpot objects updated and created.

Installation

Install as you would normally install a contributed Drupal module. For further information, see Installing Drupal Modules.

Requirements

The module requires the HubSpot Api module. Unfortunately, the HubSpot Api module branch 2.x and release 2.0.2 is not compatible with the HubSpot Api v3 SDK, thus the following repository has to be added to composer.json file repositories section:

{
  "type": "package",
  "package": {
    "name": "drupal/hubspot_api",
    "type": "drupal-module",
    "version": "dev-8.x-2.x",
    "source": {
      "type": "git",
      "url": "https://git.drupalcode.org/project/hubspot_api",
      "reference": "70251ba04f82a6908b5e20a7f619250b4d86b081"
    }
  }
}

In require section use above repository version: "drupal/hubspot_api": "dev-8.x-2.x"

And use this patch: https://www.drupal.org/files/issues/2023-05-02/hubspot_api-switch-to-hub...

Add the new hubspot/api-client:

composer require hubspot/api-client:^9.4 -W
composer install -o

Configuration

The module does not provide any configuration.

Usage

In case you do not need to sync special fields to HubSpot, you just need to enable the module and set the HubSpot Private app key in the HubSpot api settings form.

The base module sync Drupal Users to HubSpot Contacts.

There are two other modules provided to sync content:

The hubspot_commerce module is for Drupal Commerce sites, it syncs commerce_orders, commerce_order_items and commerce_products to HubSpot Deals, Line items and Products.

The hubspot_sync module syncs HubSpot object IDs to Drupal entities to store HubSpot object id in the Drupal entity's hubspot_id field. After this process, you can sync the Drupal entities to HubSpot objects.
In case you need special entities and/or fields to be synced to HubSpot, you need to create a custom module and implement event subscriber to the following events:

  • EntityMappingEvent
  • FieldMappingSyncFromEvent
  • FieldMappingSyncToEvent
  • FieldSyncIdentifyFieldsEvent
  • SyncFromEntityUpdateEvent
  • SyncPostRequestEvent
  • SyncPreRequestEvent

Find example in the hubspot_commerce module.

In case you need other Drupal entities to be synced to HubSpot, you need to implement the hook_entity_base_field_info hook and add the hubspot_id field to the entity.

/**
 * Implements hook_entity_base_field_info().
 */
function mymodule_entity_base_field_info(EntityTypeInterface $entity_type) {
  $fields = [];
  $entity_types = [
    'my_entity_type_id',
    'my_other_entity_type_id',
  ];
  foreach ($entity_types as $entity_type_name) {
    if ($entity_type->id() === $entity_type_name) {
      $fields['hubspot_id'] = BaseFieldDefinition::create('string')
        ->setLabel(t('Hubspot ID'))
        ->setDescription(t('The Hubspot ID for entity.'))
        ->setSettings([
          'max_length' => 255,
          'default_value' => NULL,
        ]);
    }
  }

  return $fields;
}

If this field is added to an existing module you need to implement the update hook as well.

Maintainers
Dudás József

Activity

Total releases
1
First release
Mar 2025
Latest release
11 months ago
Release cadence
Stability
100% stable

Releases

Version Type Release date
1.0.1 Stable Mar 18, 2025