There are multiple ways install the HubSpot tracking code on your Drupal website. This article focuses on two methods:
You can install the HubSpot module within Drupal for a quicker method of installing the HubSpot tracking code on all your Drupal-hosted pages.
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.
- Click on + Add 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.
- Click Save block.