Become a HubSpot power user — join us for HubSpot Training Day 2017.


How do I install the HubSpot tracking code on a Drupal site?

Last updated: May 15, 2017

Available For:

Marketing: Free, Starter, Basic, Pro, Enterprise
Sales: Free, Professional

There are multiple ways install the HubSpot tracking code on your Drupal website. This article focuses on two methods:

1. Using the HubSpot module.

2. Using a Drupal block.


Using the HubSpot module

You can install the HubSpot module within Drupal for a quicker method of installing the HubSpot tracking code on all your Drupal-hosted pages.


Using a Drupal block

1. Copy the HubSpot tracking code

Copy your HubSpot tracking code by following the instructions here.


2. Install the tracking code on your Drupal site

Once you have copied your HubSpot tracking code:

  • Log into your Drupal admin dashboard.
  • Click on Structure in the top menu.
  • Select Blocks.
    drupal settings
    drupal settings
  • Click on + Add Block.
    add drupal block
    add drupal block
  • Complete the following settings for your new block:
    • Block title: Provide a title for your block, ex. HubSpot Tracking Code.
    • Block description: Provide a description of the block, ex: Track website analytics with HubSpot's tracking code. 
    • Block body: Paste the HubSpot tracking code copied above.
    • Text format: Choose Full HTML.  Please note that in some versions of Drupal, you may need to click Plain Text Editor beneath the Block Body field to ensure that your text is entered as HTML instead of rich text. 
    • Region settings: Choose 'Footer' for your default theme.
    • Visibility settings: If you do not want the HubSpot tracking code to track analytics for certain pages, add them in this section. Otherwise, skip this section.
    drupal block settings
    drupal block settings
  • Click Save block.

Was this article helpful?