Skip to content
Login Contact

HubSpot integration for page tracking and conversions

The Marfeel HubSpot integration lets marketers track page performance, measure form conversions, and map HubSpot user journey stages directly inside Compass. This out-of-the-box connection covers three core capabilities:

  1. Track the performance of sites or blogs built with HubSpot
  2. Understand which stories drive the most conversions
  3. Map HubSpot user journey stages to Marfeel user journey stages, revealing which stories your leads and prospects consume

To start measuring HubSpot page data with Compass, add the Marfeel JavaScript SDK to your site header.

Go to Settings > Tools > Website > Pages > Templates > HTML > Site header

Add this code into the Site Header HTML text area, replacing /accountId/ with your Marfeel AccountId:

<script type="text/javascript">
function e(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],c=document.createElement("script");c.src=e,t?c.type="module":(c.async=!0,c.type="text/javascript",c.setAttribute("nomodule",""));var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(c,n)}function t(t,c,n){var a,o,r;null!==(a=t.marfeel)&&void 0!==a||(t.marfeel={}),null!==(o=(r=t.marfeel).cmd)&&void 0!==o||(r.cmd=[]),t.marfeel.config=n,t.marfeel.config.accountId=c;var i="https://sdk.mrf.io/statics";e("".concat(i,"/marfeel-sdk.js?id=").concat(c),!0),e("".concat(i,"/marfeel-sdk.es5.js?id=").concat(c),!1)}!function(e,c){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};t(e,c,n)}(window, /*accountId*/,{} /*config*/);
</script>

HubSpot site header settings showing where to paste the Marfeel SDK script|613x574

Important
Review that the option "Default settings for all domains" is selected, and verify that subdomains don't have a "custom" script. If a subdomain contains a script, that script is going to overwrite the "Default script" with the Marfeel tracking code.

HubSpot domain settings showing default versus custom script options|350x132

To track conversions from HubSpot forms, add the following event listener after the Compass tracking script.

Update the tag created in the previous step and add this code before the closing tag:

window.addEventListener('message', function(event) {
if(event.data.type === 'hsFormCallback' && event.data.eventName === 'onFormSubmit') {
window.marfeel.cmd.push(['compass', function(compass) {
compass.trackConversion('HS form submit');
compass.trackConversion('HS id: ' + event.data.id);
}]);
}
});

The combined script should look like this:

<script type="text/javascript">
function e(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],c=document.createElement("script");c.src=e,t?c.type="module":(c.async=!0,c.type="text/javascript",c.setAttribute("nomodule",""));var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(c,n)}function t(t,c,n){var a,o,r;null!==(a=t.marfeel)&&void 0!==a||(t.marfeel={}),null!==(o=(r=t.marfeel).cmd)&&void 0!==o||(r.cmd=[]),t.marfeel.config=n,t.marfeel.config.accountId=c;var i="https://sdk.mrf.io/statics";e("".concat(i,"/marfeel-sdk.js?id=").concat(c),!0),e("".concat(i,"/marfeel-sdk.es5.js?id=").concat(c),!1)}!function(e,c){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};t(e,c,n)}(window, /*accountId*/,{} /*config*/);
window.addEventListener('message', function(event) {
if(event.data.type === 'hsFormCallback' && event.data.eventName === 'onFormSubmit') {
window.marfeel.cmd.push(['compass', function(compass) {
compass.trackConversion('HS form submit');
compass.trackConversion('HS id: ' + event.data.id);
}]);
}
});
</script>

To connect the Marfeel HubSpot application to your account, follow these steps:

  1. Open the following URL in your browser, replacing <site_id> with your Marfeel account ID:

    https://app-eu1.hubspot.com/oauth/authorize?client_id=245b5d05-8f7e-4075-800b-d9dc988e0fd3&redirect_uri=https://marfeelwhois.mrf.io/hubspot/authorized&scope=files%20crm.objects.contacts.read%20crm.objects.contacts.write&state=<site_id>

  2. Select the account to link: HubSpot account selection dialog for linking with Marfeel|294x225

  3. The Marfeel application is still an unverified app. When choosing to connect, you will be prompted with a captcha. HubSpot captcha prompt for connecting an unverified application|326x331

  4. Once the process completes you will be redirected to a page showing a JSON response similar to this:

​​{"token_type":"bearer","hub_id":"25210399","refresh_token":"eu1-98e1-9214-4b43-bda6-502b97216d04","access_token":"CNn904rPLxIEAAEAQBif3IIMIJzz7AwozsocMhRy9vT1fydAOPESphGClJH_evHcWpM8jljoasdfbaswAAAAQQAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAAAAAAAAACQhS8WQwlWpR0m2GNiM6XjleL871DLEoDZXUxUgBaXX","expires_in":21600,"expiration_time":1636136452341,"site_id":1234}

Verify the installation was successful from Hubspot account > settings > integrations > connected apps:

HubSpot connected apps settings showing a successful Marfeel integration|470x124

Go to Organization Settings > User Journey and create the HubSpot stages: Lead, Marketing Qualified Lead, Sales Qualified Lead, Opportunity, Customer, Evangelist, Other.

HubSpot user journey stage configuration in Marfeel Organization Settings|690x449

After completing the setup, Compass shows in real time which stories your readers consume based on their HubSpot qualification. This user journey data is available across all modules.

Real-time HubSpot user journey report showing reader engagement by qualification stage|690x449

Content performance breakdown by HubSpot user journey stage|690x449

How do I track HubSpot pages with Marfeel Compass?

Add the Marfeel SDK script to your HubSpot site header at Settings > Tools > Website > Pages > Templates > HTML > Site header. Replace the accountId placeholder with your Marfeel AccountId. Make sure “Default settings for all domains” is selected so subdomain scripts do not overwrite the tracking code.

How do I track HubSpot form conversions in Marfeel?

Add a message event listener after the Compass tracking script that listens for the hsFormCallback event with an onFormSubmit action. The listener calls compass.trackConversion with both a generic label and the specific form ID.

How do I set up HubSpot user journey stages in Marfeel?

Go to Organization Settings > User Journey and create the HubSpot stages: Lead, Marketing Qualified Lead, Sales Qualified Lead, Opportunity, Customer, Evangelist, and Other. After setup, real-time reports show reader interests based on their HubSpot qualification across all modules.