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.
Copy the HubSpot tracking code
- Navigate to Reports > Reports Settings.
- Locate your tracking code and click Copy to clipboard.
Install the tracking code on your Drupal site
- 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.