Assign API contact to Campaign



Hi Guys

For a lead generated outside Hubspot we have 2 ways of getting that contact into Hubspot via the API. We can use the Contacts API to create the contact or we can use the Forms API to post to a form that creates the contact. My question is, how can we assign this contact to a particular Campaign? I can’t see anything in either API that will allow us to do this.

If a form could be associated with a Campaign that would be the easy solution, but I understand that forms cannot be assigned to Campaigns.

I’ve also tried submitting a Page Name via the forms API (that page name matches a landing page which belongs to the relevant campaign) but doing this does not assign the contact to the matching campaign.

Any help appreciated.

Thanks very much.



Hi @firoze

If you’re using the Forms API, you can include the id of the landing page in the pageId in hs_context to associate the submission with that page, which would count the contact towards the campaign if the page is associated with a campaign.


Hi Dan

First of all thanks very much for your really helpful reply. For a few weeks I thought it wasn’t working but now I reckon it is.

I pass the ID of the landing page back via pageId in hs_context. When I view the customer’s timeline I would expect to see something like:


However it actually says:

John submitted FORM_NAME on FORM_NAME

So that’s why I thought it wasn’t working.

But today I created list, filtering on all contacts who filled ANY form on LANDING_PAGE_NAME and these contacts came up in the list.

So I thought I’d mention this here for two reasons:

a) To check to see if you thought this was expected behaviour
b) It might be of help to some other users here