Summer promotion background
1st – 31st July 2026

AI Agents at Zero Cost

Get your

33% off

+ free AI Agent

Use code for monthly and for yearly subscription

HubSpot leads

HubSpot AffiliateMarketing E-commerce CMS

HubSpot leads integration

Besides other features, HubSpot offers you a way to track custom forms. The integration of these forms will help you track lead commissions.

The integration uses the form’s ‘onBeforeFormSubmit’ function.

The standard form code looks like this:

<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/embed/v2.js"></script>
<script>
  hbspt.forms.create({
    portalId: "1234567",
    formId: "123c30ab-f09e-4c9a-ae7f-123e456f7f89"
  });
</script>

The sale (lead) tracking code will be placed to the ‘onBeforeFormSubmit’ function mentioned above, like this:

<script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/embed/v2.js"></script>
<script>
  hbspt.forms.create({
    portalId: "1234567",
    formId: "123c30ab-f09e-4c9a-ae7f-123e456f7f89",
    onBeforeFormSubmit: function ($form, submissionValues) {
        var email = '';

        submissionValues.forEach(function(currentValue, index, arr){
            if (currentValue.name == "email") {
                email = currentValue.value;
            }
        });

        var sale = PostAffTracker.createSale();
        sale.setOrderID(email);
        sale.setProductID('__Form name/Id here__');
        sale.setData1(email);
        PostAffTracker.register();
    }
  });
</script>

In case you need help with this sale/lead tracking code, feel free to get in touch with us.

Click tracking

Do not forget this important step. The code added to HubSpot forms requires the click tracking code to be present in the same page. Add the click tracking code anywhere to the page with your HubSpot form – it does not matter if you place it before or after the HubSpot form’s code.

Frequently asked questions

Lucia is a talented content editor who ensures the seamless publication of content across multiple platforms.

Lucia Halašková
Lucia Halašková
Content Editor

Try Post Affiliate Pro for Free

Experience seamless affiliate tracking and integration with HubSpot leads. Start your free trial today and optimize your affiliate network.

Learn more

Zoho Forms
Zoho Forms

Zoho Forms

Learn how to integrate Zoho Forms with Post Affiliate Pro for seamless affiliate management. Simplify data collection, automate workflows, and track sales with ...

5 min read
Integration Zoho Forms +3
Calendly
Calendly

Calendly

Learn how to integrate Calendly with Post Affiliate Pro for seamless scheduling automation and affiliate tracking. Discover features, setup steps, pros, cons, p...

5 min read
Calendly AffiliateMarketing +3

You will be in Good Hands!

Join our community of happy clients and provide excellent customer support with Post Affiliate Pro.

Capterra
G2 Crowd
GetApp
Post Affiliate Pro Dashboard - Campaign Manager Interface