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.
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.