HubSpot – inbound marketing

HubSpot helps you get found by customers. It provides tools for content creation, conversion and marketing analysis. HubSpot uses tracking on your website to measure effect of your marketing efforts.


To start using the HubSpot integration, you must have installed the django-analytical package and have added the analytical application to INSTALLED_APPS in your project file. See Installation and configuration for details.

Next you need to add the HubSpot template tag to your templates. This step is only needed if you are not using the generic analytical.* tags. If you are, skip to Configuration.

The HubSpot tracking code is inserted into templates using a template tag. Load the hubspot template tag library and insert the hubspot tag. Because every page that you want to track must have the tag, it is useful to add it to your base template. Insert the tag at the bottom of the HTML body:

{% load hubspot %}
{% hubspot %}


Before you can use the HubSpot integration, you must first set your portal ID, also known as your Hub ID.

Setting the portal ID

Your HubSpot account has its own portal ID, the hubspot tag will include them in the rendered JavaScript code. You can find the portal ID by accessing your dashboard. Alternatively, read this Quick Answer page. Set HUBSPOT_PORTAL_ID in the project file:


If you do not set the portal ID, the tracking code will not be rendered.

Deprecated since version 0.18.0: HUBSPOT_DOMAIN is no longer required.

Internal IP addresses

Usually you do not want to track clicks from your development or internal IP addresses. By default, if the tags detect that the client comes from any address in the HUBSPOT_INTERNAL_IPS setting, the tracking code is commented out. It takes the value of ANALYTICAL_INTERNAL_IPS by default (which in turn is INTERNAL_IPS by default). See Identifying authenticated users for important information about detecting the visitor IP address.