Documentation menuContent management systems: HubSpot

Content management systems

Add Loogika to HubSpot

In HubSpot Content Hub, which used to be called CMS Hub, the Site header HTML setting inserts code into the head of all content on a domain. Paste the Loogika tag there and it loads on website pages, landing pages, blog posts and knowledge base articles. You do not edit any template.

Last updated .

What do you need before you start?

Copy your script tag from Site Settings in Loogika, under the Tracking Script tab. It looks like this, with your own site ID in place of YOUR_SITE_ID:

<script src="https://app.loogika.com/api/script.js?siteId=YOUR_SITE_ID" defer></script>

How do you add Loogika to every HubSpot page on a domain?

Use the Site header HTML field in your HubSpot settings. The tag then loads on all content that HubSpot hosts on the domain.

  1. Click the settings icon in the top bar of your HubSpot account.
  2. Go to Content, then Pages, in the left sidebar.
  3. Find the dropdown labelled Choose a domain to edit its settings, and pick the domain there. Stay on the default settings if the tag should apply to every domain.
  4. Paste the tag into the Site header HTML field.
  5. Click Save.

A domain with Override default settings turned on ignores the default header code. Paste the tag into the settings of that domain as well.

How do you add Loogika to a single HubSpot page?

Paste the tag into the Head HTML field of the page. The page method fits when you want to track a single page, or when the domain settings are in the hands of another person.

  1. Go to Content, then Website Pages. A click on the name of the page opens the editor. Landing Pages, Blog and Knowledge Base work the same way.
  2. Click the Settings menu and select Advanced.
  3. Find Additional code snippets and paste the tag into the Head HTML field.
  4. Click Update or Publish.

HubSpot adds the Head HTML of a page on top of the Site header HTML. A page that has the tag in both places loads the script twice, so pick one method.

How do you track HubSpot form submissions?

Send a custom event when the form is submitted. No new pageview marks the submission, because the page does not reload when a visitor sends a HubSpot form.

HubSpot posts a message to the page when a form has been submitted. Place the script below after the Loogika tag to turn that message into an event called form_submitted:

<script>
  window.addEventListener("message", function (event) {
    if (event.data.type === "hsFormCallback" && event.data.eventName === "onFormSubmitted") {
      window.loogika?.event("form_submitted", { formId: event.data.id });
    }
  });
</script>

For a call-to-action button you need no JavaScript. Add the data-loogika-event attribute to the button, as shown on the track events page.

How do you check that Loogika is installed?

Load a published page in a fresh browser tab and visit a few pages. The pageviews appear in the Loogika dashboard within a few seconds. If nothing arrives, open the page source and look for script.js?siteId=.

Why does HubSpot show no data or double pageviews?

SymptomCause and fix
The tag is missing on one domainSite header HTML is set per domain. Check whether the domain has Override default settings turned on, and paste the tag into its own settings
Every pageview counts twiceThe page has the tag in Site header HTML and in its own Head HTML. Remove one of them
Visits appear while you editThe content editor renders the page in an iframe with unpublished changes. A preview that loads the script counts as a visit, so check your numbers on the published site
Quotes show up in the reportsHubSpot quotes that live on a domain also receive the header HTML you set for that domain