Openli
IntroductionGetting StartedTechnical DocumentationGet help
  • Getting started
    • Introduction
    • Dictionary
    • FAQ
      • IAB TCF v2.0
  • Privacy hub
    • How to create your privacy profile
    • How can I get an Openli Privacy Badge?
    • Vendor owners
    • Why are custom properties on vendors super valuable?
    • Setting up custom properties
  • Tasks
  • Cookie Consent Management
    • Quickstart
    • Checklist: Cookies
    • Cookie widget
      • Create a cookie policy
      • Create a cookie widget
      • Install the widget
      • Manually add any cookies
      • Customise your widget
      • How to get color codes
      • Set the widget language
      • Use custom link/button instead of Cookie Shield
      • Add company name to cookie pop-up
    • Categorise your cookies
    • Adding information to cookies
    • Adding information to your cookie providers
    • Blocking Cookies with Openli
    • Cookie expiration dates and lifespan
      • Changing expiration on Google Analytics cookies
  • Policy and agreement management
    • Generate your privacy policy
    • Changing an old cookie policy to a new on autopilot
    • Embed your policies and legal agreements
      • Embedding agreements without displaying a widget
    • Install the Privacy Badge
  • General Openli guides
    • Setting up SSO (Single Sign-On)
      • SSO with Azure AD (Microsoft)
      • SSO with Google
      • SSO with Okta
      • How to log in with SSO
    • Add a website to your Openli account
    • Using projects to handle multiple languages
    • Collect consents without storing IP addresses or user-agents
  • Technical documentation
    • Widget
      • Collect cookie consent
        • Blocking cookies
        • Blocking embedded media
        • Cookie-widget options
        • Consent state API
    • API
      • Services
        • Personal data
        • Subprocessors
    • Cookies set by Openli
  • System Specific Integration Guides
    • Cloudflare
  • Legacy integrations
    • Google Consent Mode
    • Google Tag Manager
      • Block cookies with GTM
      • Install Openli with GTM
      • Prevent triggers from firing in GTM
    • HubSpot
    • Pardot
    • Shopify
      • Install cookie widget
      • Integrate consent with checkout
    • Square Online
    • Squarespace
    • Webflow
    • Wix
Powered by GitBook
On this page
  • Requirements
  • Integrating Openli on a HubSpot-hosted site
  • Step 1: Activate HubSpot's (non-compliant) cookie-consent banner
  • Step 2: Add code to your site to integrate Openli and HubSpot
  • Step 3: Add the Openli cookie-consent widget to your site
  1. Legacy integrations

HubSpot

This guide explains how to integrate the Openli cookie widget on a site that is hosted by HubSpot.

PreviousPrevent triggers from firing in GTMNextPardot

Last updated 8 months ago

This courtesy guide is no longer actively tested by Openli, although it might still work.

Our cookie-consent widget intentionally uses a highly-compatible, highly-generic approach to integration. In most cases, it will be possible for your developers to adapt this guide's steps to any changes that might have been made to the target platform, in combination with their own general documentation. Our might be useful for this.

Requirements

  1. A Openli cookie widget, with a published cookie policy, ready to install

  2. A website hosted on HubSpot

Integrating Openli on a HubSpot-hosted site

Step 1: Activate HubSpot's (non-compliant) cookie-consent banner

HubSpot do not currently provide an adequate way for us to communicate consent status to their own platform, so you must activate HubSpot's built-in cookie-consent banner. Openli's cookie widget will then use this behind the scenes, supplementing our own consent management, and providing the best current level of integration with HubSpot.

, and your cookie-banner settings should look like this:

HubSpot's built-in cookie-consent banner, when used on its own, is not sufficient to ensure compliance with the GDPR and other similar privacy laws. Using Openli's cookie-consent widget helps to close this compliance gap.

Step 2: Add code to your site to integrate Openli and HubSpot

<style>
    /* Hide the HS cookie-banner.
    It is controlled through the LM widget instead. */
    #hs-eu-cookie-confirmation {
        display: none !important;
    }
</style>
<script>
    // These will be set to true if the user has already consented when
    // the events below are run.
    var analyticsConsent = false;
    var marketingConsent = false;

    function handleConsent() {
        // If the user accepts both analytics and
        // marketing, HubSpot's cookies can be set.
        if (analyticsConsent && marketingConsent) {
            // Get a reference to the HubSpot cookie-banner's accept button.
            acceptButton = document.querySelector("#hs-eu-confirmation-button");
            // If the button exists (a decision was not already taken), click it.
            acceptButton && acceptButton.click();
        }
    }

    // Listen for acceptance of analytics consent.
    window.addEventListener(
        "legalmonster.cookie.analytics.accepted",
        function() {
            analyticsConsent = true;
            handleConsent();
        }
    );
    // Listen for acceptance of marketing consent.
    window.addEventListener(
        "legalmonster.cookie.marketing.accepted",
        function() {
            marketingConsent = true;
            handleConsent();
        }
    );
  
    // If either analytics or marketing consent is refused or revoked,
    // trigger HubSpot's cookie-refusal method.
    function refuseHubSpotCookies() {
        // HubSpot documentation:
        // https://developers.hubspot.com/docs/methods/tracking_code_api/remove_cookies
        var _hsp = window._hsp = window._hsp || [];
        _hsp.push(["revokeCookieConsent"]);
    }
    // Listen for rejection of analytics consent.
    window.addEventListener(
        "legalmonster.cookie.analytics.rejected",
        function() {
            analyticsConsent = false;
            refuseHubSpotCookies();
        }
    );
    // Listen for rejection of marketing consent.
    window.addEventListener(
        "legalmonster.cookie.marketing.rejected",
        function() {
            marketingConsent = false;
            refuseHubSpotCookies();
        }
    );
</script>

Because HubSpot provide only an "accept all"/"reject all" option for their cookies, consent must be given to analytics and marketing cookies before HubSpot's cookies can be enabled. We strongly recommend using the option in your Openli cookie widget to present an "Accept all" button to users, to make it simpler to opt in to the categories HubSpot use.

Step 3: Add the Openli cookie-consent widget to your site

<script>
    !function(){var i,e,t,s=window.legal=window.legal||[];if(s.SNIPPET_VERSION="3.0.0",i="https://widgets.legalmonster.com/v1/legal.js",!s.__VERSION__)if(s.invoked)window.console&&console.info&&console.info("legal.js: The initialisation snippet is included more than once on this page, and does not need to be.");else{for(s.invoked=!0,s.methods=["cookieConsent","document","ensureConsent","handleWidget","signup","user"],s.factory=function(t){return function(){var e=Array.prototype.slice.call(arguments);return e.unshift(t),s.push(e),s}},e=0;e<s.methods.length;e++)t=s.methods[e],s[t]=s.factory(t);s.load=function(e,t){var n,o=document.createElement("script");o.setAttribute("data-legalmonster","sven"),o.type="text/javascript",o.async=!0,o.src=i,(n=document.getElementsByTagName("script")[0]).parentNode.insertBefore(o,n),s.__project=e,s.__loadOptions=t||{}},s.widget=function(e){s.__project||s.load(e.widgetPublicKey),s.handleWidget(e)}}}();

    legal.widget({
        type: "cookie",
        widgetPublicKey: "...",
    });
</script>

Add this code to the head (not the footer) of your site, :

Add code like this, from your cookie-widget settings, to the footer (not the head, unlike before) of your site, :

The approach used in the guide is very similar to for integrating third-party cookie-consent solutions like Openli. We therefore expect HubSpot to continue to support it, but all changes they make are outside our control.

following HubSpot's general guide
following HubSpot's general guide again
HubSpot's own recommendation
HubSpot have a general guide to enabling their banner here
consent-state events