Tracking Code

Customize cookie tracking settings and privacy policy alert

Last updated: February 24, 2021

Applies to:

All products and plans

Super Admins and users with permission to edit website settings can customize visitor cookie tracking and privacy policy banners to comply with EU cookie laws and the General Data Protection Regulation (GDPR).

A privacy alert allows visitors to opt in or opt out of being tracked in your HubSpot account with cookies. This feature works for all HubSpot pages as well as any external pages with your HubSpot tracking code installed.

Please note: while HubSpot has cookie tracking and privacy policy settings, your legal team is the best resource to give you compliance advice for your specific business circumstances.


How does HubSpot track website visitor activity?

HubSpot uses cookies to track your website visitors and contacts. A cookie is a small text file that is left behind on a visitor's browser when they come to your site. When the HubSpot software runs on your website, it leaves behind a cookie on your visitors’ browsers that helps HubSpot identify them on future visits.

Should I adjust my privacy policy?

If your business has a presence in Europe, or if you store any data on contacts in the European Union (EU), you must adjust your privacy policy to comply with EU laws. The EU has mandated that member countries create laws that require websites to gain consent from end users prior to storing data on a website visitor’s computer. These regulations are designed to help your website visitors protect their privacy and determine how their behaviors online are used by others.

Under the GDPR, if a contact of yours is an EU citizen, they must be given notice that you're using cookies to track them (in a language they can understand), and they need to consent to being tracked by cookies.

HubSpot allows you to set this privacy policy, show it to your visitors, and prompt them to consent to allow cookies to comply with EU regulations.

Set up and edit your cookie policy

Please note: only Super Admins and users with permission to edit website settings can set up and edit cookie policies.

Customize your default cookie policy

  • In your HubSpot account, click the settings icon settings in the main navigation bar.
  • In the left sidebar menu, navigate to Privacy & Consent.
  • Click the Cookies tab.
  • Click Default policy.
  • In the right panel, you have the following options:
    • Notify visitors that your site uses cookies: click to toggle the switch on to display a notification to your visitors to show that your site uses cookies.
    • Require opt-in: click to toggle the switch on to require users to opt in to cookie tracking.
    • Display cookies by category: click to toggle the switch on to show your visitors the cookies that will be put on their browser by category. This is only available if opt-in is required. Learn more about the cookies and their categories.
  • If you toggle the Notify visitors that your site uses cookies switch on, you can customize the following fields:
    • Notification terms text: text displayed in your privacy banner.
    • Accept button label: button text visitors click to accept your privacy banner's terms.
    • Decline button label: button text visitors click to decline your privacy banner's terms.
    • Disclaimer text: text displayed if opt-in is required for tracking.
  • If you toggle the Display cookies by category switch on, you must customize the following fields for each cookie category. To edit these fields for a specific category, click the cookie category name to expand the editing options:
    expand-cookie-category-fields 
    • Cookie settings button label: enter the text that the visitor can click in the cookie policy banner to view the cookies by category.
    • Label: for each category, enter the label you want for the category. This will be displayed in the left panel and the top of the right panel in the cookie policy's dialog box.
    • Description: for each category, enter the description for the category. This will be displayed in the right panel in the cookie policy's dialog box.
    • Always active toggle label: for the Necessary cookies category, enter text for the upper right toggle to explain that these cookies will be active. Because these cookies are necessary, visitors can't opt out of this individual category when they accept the terms of your privacy banner.
    • Accept all button label: enter text for the button that visitors can click to accept all categories of cookies.
    • Save button label: enter text for the button that visitors can click to save their cookie preferences.

  • When you're done, click Publish and click Save in the bottom left.
  • You've set up your cookie policy banner but have not published it. To publish a policy, click to toggle the switch the right of the policy on. Below the table on the left, click the Preview Notification link to see how the privacy policies will appear on your site.

    deafult-policy-publish-and-preview

If you want to allow users to edit their consent, you can work with a developer to implement that functionality using the HubSpot Tracking Code API. Learn more about implementing additional consent status and cookie removal functions in the developers documentation.

If you want to allow users to revoke their consent for cookies installed by the cookie banner, check out the following steps to add a cookie settings button.

Please note: if you're using the HubSpot ads tool to add a pixel to pages with the HubSpot tracking code, your privacy policy banner will automatically display when the pixel fires on your pages. If you require visitors to opt into cookie tracking, the pixel will not be able to place any cookies until the visitor confirms their consent.

Add a new cookie policy (optional)

You can choose to show different versions of your cookie consent message based on domains, subdomains, specific URL paths, or both domains and URL paths that you specify. For example, you can choose not to have an opt-in banner for your US site, and only require an opt-in banner for your EU site.

  • In your HubSpot account, click the settings icon settings in the main navigation bar.
  • In the left sidebar menu, navigate to Cookies.
  • Click + Add policy. In the right panel, you have the following options:
    • Policy label: enter the title of your privacy banner.
    • Domain: enter a domain or subdomain where your banner will appear. This must be entered as a domain without the protocol (e.g., hubspot.com or info.hubspot.com is acceptable, but not http://info.hubspot.com).
    • URL Path: set a subdirectory for a more targeted banner (e.g., if the French version of your website is hosted on the /fr subdirectory, enter fr).

Please note: if a page URL matches multiple policy rules, the most specific rule will take priority (in order from most to least specific: (sub)domain and URL path, URL path, (sub)domain, then the default policy). For example, you may have three policies for the following domains and or URL paths: info.hubspot.com, info.hubspot.com/fr, and /fr. A visitor to info.hubspot.com/fr/offer will see the info.hubspot.com/fr policy, while a visitor to info.hubspot.com/fr will see the policy for the /fr URL path.

  • Click Next. Now, you can customize your notifications to your visitors.
    • Notify visitors that your site uses cookies: click to toggle the switch on to display a notification to your visitors to show that your site uses cookies. If this is toggled on, click the Choose a language dropdown menu below to select the language for your notification. You can then customize your notification.
    • Require opt-in: click to toggle the switch on to require users to opt in to cookie tracking.
    • Display cookies by category: click to toggle the switch on to show your visitors the cookies that will be put on their browser by category. This is only available if opt-in is required. Learn more about the cookies and their categories.
  • If you toggle the Notify visitors that your site uses cookies switch on, you can customize the following fields:
    • Notification terms text: text displayed in your privacy banner.
    • Accept button label: button text visitors click to accept your privacy banner's terms.
    • Decline button label: button text visitors click to decline your privacy banner's terms.
    • Disclaimer text: text displayed if opt-in is required for tracking.
  • If you toggle the Display cookies by category switch on, you must customize the following fields for each cookie category. To edit these fields for a specific category, click the cookie category name to expand the editing options:
    expand-cookie-category-fields 
    • Cookie settings button label: enter the text that the visitor can click in the cookie policy banner to view the cookies by category.
    • Label: for each category, enter the label you want for the category. This will be displayed in the left panel and the top of the right panel in the cookie policy's dialog box.
    • Description: for each category, enter the description for the category. This will be displayed in the right panel in the cookie policy's dialog box.
    • Always active toggle label: for the Necessary cookies category, enter text for the upper right toggle to explain that these necessary cookies will be active.
    • Accept all button label: enter text for the button that visitors can click to accept all categories of cookies.
    • Save button label: enter text for the button that visitors can click to save their cookie preferences.

  • When you're done, click Publish and click Save in the bottom left.
  • The cookie policy is now published. To unpublish a policy so it doesn't appear on your site, click to toggle the switch to the right of the policy off.
  • Below the table on the left, click the Preview Notification link to see how the privacy policies will appear on your site.

    deafult-policy-publish-and-preview-1

If you want to allow users to edit their consent further, you can work with a developer to implement that functionality using the HubSpot Tracking Code API. Learn more about implementing additional consent status and cookie removal functions in the developers documentation.

If you want to allow users to revoke their consent for cookies installed by the cookie banner, check out the following steps to add a cookie settings button.

Please note: if you're using the HubSpot ads tool to add a pixel to pages with the HubSpot tracking code and your cookie policy requires visitors to opt into cookie tracking, the pixel will only place cookies once the visitor confirms their consent in your privacy policy banner.

Customize the style of the banner

Customize the colors and style of your cookie policy banner.

  • In your HubSpot account, click the settings icon settings in the main navigation bar.
  • In the left sidebar menu, navigate to Cookies.
  • Select Top or Bottom banner position depending on where you want the banner to appear on your site.
  • Choose a color for the banner by selecting a default color or selecting a custom color. The colors chosen are determined by your brand colors.
  • In the bottom left, click Save.

cookie-policy-style-and-preview

Deactivate cookies on certain pages

You can deactivate cookies on certain pages, based on the URL.

  • In your HubSpot account, click the settings icon settings in the main navigation bar.
  • In the left sidebar menu, navigate to Cookies.
  • Click + Add policy. In the right panel, you have the following options:
    • Policy label: enter a title for this policy that will deactivate cookies on the URL path you enter.
    • Domain: enter a domain or subdomain where cookies will be deactivated. This must be entered as a domain without the protocol (e.g., hubspot.com or info.hubspot.com is acceptable, but not http://info.hubspot.com).
    • URL Path: set a subdirectory to target more specifically where the cookies will be deactivated (e.g., if you want to deactivate cookies on all pages in the /private subdirector, enter /private).
  • Select Deactivate cookies. This will deactivate all cookies on this URL path.
  • Click Publish.

You can also check out our developer documentation for more information on disabling cookies.

Add a Cookie Settings button to the cookie policy banner

To add a button for users to re-open the cookie policy banner and revoke their cookie consent to the cookies implemented or loaded by the cookie policy banner:

  • In your HubSpot account, click the settings icon settings in the main navigation bar.
  • In the left sidebar menu, navigate to Cookies.
  • In the Cookie settings button section, click Copy to copy the code.
  • Add the code to the pages of your site that has the HubSpot tracking code, where you want the Cookie settings button to appear.

If you want to install the code on all pages, most content management systems can install code to all pages on your site, such as a footer file that is referenced across all pages. In HubSpot, you can add the code to the footer HTML of all pages on a specific domain. Please check with your developers on how they can help do this on external sites.

Understand how contacts interact with the cookie policy banner

If a visitor accepts your privacy policy, you can track them with the cookie settings you've set up in your account. If a visitor declines your privacy policy, they will not be tracked with cookies.

Please note: this cookie policy banner controls:

  • HubSpot cookies on HubSpot-hosted pages and externally hosted pages with the HubSpot tracking code; and
  • Google Analytics script only on HubSpot-hosted pages when the Google Analytics code is added on the Integrations tab in your HubSpot settings. This is effective as of November 1, 2019.

If your HubSpot cookie banner is set to require opt-in, these scripts will not load until the visitor accepts the HubSpot cookie banner. HubSpot is unable to control the cookies placed by other scripts on your website. Learn more about using the banner for third-party scripts.

View a single contact's interaction with the cookie policy banner

To view a single contact's interaction with the cookie policy banner:

  • In your HubSpot account, navigate to Contacts > Contacts.
  • Click the name of the contact to check their interaction with the cookie policy banner.
  • Check the contact's timeline for a consent event. If the contact interacted with the banner, it should state if the contact accepted, declined or revoked the cookie policy banner.

Create a list of contacts based on their interaction with the cookie policy banner

To create a list of contacts who've had a certain interaction with the cookie policy banner:

  • In your HubSpot account, navigate to Contacts > Lists.
  • In the upper right, click Create list.
  • In the upper left, enter the name of your list.
  • In the left panel, select Contact properties and then, Privacy Consent.
  • Select the appropriate filter and value.
    • Approved: the contact accepted the cookie policy banner.
    • Declined: the contact declined the cookie policy banner.
    • Revoked: the contact's cookies were removed. Learn more about the Remove cookies API.
  • Click Save and let the list process. It will display the contacts that meet your filter criteria.