APIs & Integrations

PaulAxonGarside
Participant | Diamond Partner
Participant | Diamond Partner

API submission with conversion page recorded

Hi All

I’ve setup an API form submission on a HubSpot hosted landing page, basically so the user can submit their details and carry on using the tool we’ve built whilst their submission is made in the background.

This all works fine, except despite the submission coming from a HubSpot page I can’t get it to record the ‘Conversion Page’ under the form submissions, and so when you view the landing page details, it looks like it’s had no submissions.

That of course stands to reason as you’re not submitting via the actual form associated with the page, however in the past I managed to get round this by having an instance of the same form on the page just in a hidden container, and then also passing over the ‘pageId’ variable within the hs_context. This doesn’t seem to work anymore.

I’ve lifted everything from the hs_context input that appears on the page, parsed it to an array and passed all that across at the same time in an attempt to replicate the submission that would have been made by the actual form hidden on the page (which if I unhide and submit does record the right conversion page!) but to no avail.

Any help greatly appreciated.

Many Thanks

Paul

9 Replies 9
Derek_Gervais
HubSpot Alumni
HubSpot Alumni

API submission with conversion page recorded

Hi @Rashid_A_Omar,

pageId in an internal value for HubSpot pages, and doesn’t exist for external pages. Can you create a separate topic with some more information on your specific issue? This topic is very old and related to HubSpot hosted pages.

0 Upvotes
Not applicable

API submission with conversion page recorded

I’m also having the same problem. Conversion Page is showing as ‘Unavailable’. The particular page in question is not hosted by Hubspot. Is ‘pageId’ the correct key to pass? And what exactly would be the value of ‘pageId’?

0 Upvotes
PaulAxonGarside
Participant | Diamond Partner
Participant | Diamond Partner

API submission with conversion page recorded

Thanks @dadams, JSON.stringify on the hs_context worked. I think I was thrown by the fact it was passing over the variables on the forms page but clearly there was some issue with HubSpot reading them. All seems to work now.

Regards

Paul

0 Upvotes
PaulAxonGarside
Participant | Diamond Partner
Participant | Diamond Partner

API submission with conversion page recorded

Sorry to bump again but I’ve trawled through all the threads with similar issues and I still can’t resolve this. I tried adding a content_id parameter onto the data list but that didn’t help. Does anyone have any code they know works that they wouldn’t mind sharing?

Thanks

0 Upvotes
Dadams
HubSpot Employee
HubSpot Employee

API submission with conversion page recorded

@PaulAxonGarside the specific item you’d need would be the "pageId", which it looks like you’re already grabbing from the original hs_context. The value of pageId needs to be set to the ID of the page you’re working with. As an example, if you’re editing the page in HubSpot at this URL where your Hub Id is 12345:
https://app.hubspot.com/content/12345/edit-beta/123456789
The page ID would be 123456789, so that’s the value you’d use for pageId inside hs_context.

The only two things that jump out to me in your code is that you might need to stringify hs_context inside var data=, and that you’ll want to send the data as form-encoded and not json.

0 Upvotes
PaulAxonGarside
Participant | Diamond Partner
Participant | Diamond Partner

API submission with conversion page recorded

Sorry to bump but HubSpot support have given up on me (understandably!). They’ve said I’m not passing the hutk or pageId properly, though I’m including them in the hs_context in the jQuery post, which I thought was the right way to do it?

0 Upvotes
Dadams
HubSpot Employee
HubSpot Employee

API submission with conversion page recorded

@PaulAxonGarside do you have an example page we could take a look at? Depending on how you’re including the hs_context data there may be an issue with how that data is getting encoded in the actual POST being made.

0 Upvotes
PaulAxonGarside
Participant | Diamond Partner
Participant | Diamond Partner

API submission with conversion page recorded

Hi @dadams

Here’s the code I’m using, there’s admittedly way more stuff in there than there needs to be, but I was trying to replicate the data that a normal form submission would make:

/*
The HubSpot form I’m mimicking is actually in the template as well but hidden
I’m grabbing some of the data from that as well to try and help the submission connect up
*/
var hch = jQuery.parseJSON(jQuery(“input[name=‘hs_context’]” ).val());

var hs_context = {
“ipAddress”: ip,
“pageUrl”: pageUrl,
“pageTitle”: hch[“pageTitle”],
“isHostedOnHubspot”: hch[“isHostedOnHubspot”],
“timestamp”: hch[“timestamp”],
“userAgent”: hch[“userAgent”],
“referrer”: hch[“referrer”],
“hutk”: hch[“hutk”],
“originalEmbedContext”:{
“portalId”: hch[“originalEmbedContext”][“portalId”],
“formId”: hch[“originalEmbedContext”][“formId”],
“formInstanceId”: hch[“originalEmbedContext”][“formInstanceId”],
“pageId”: hch[“originalEmbedContext”][“pageId”],
“pageName”: hch[“originalEmbedContext”][“pageName”],
“redirectUrl”: hch[“originalEmbedContext”][“redirectUrl”],
“css”:"",
“target”: hch[“originalEmbedContext”][“target”],
“contentType”: hch[“originalEmbedContext”][“contentType”]
},
“recentFieldsCookie”:{},
“pageId”: hch[“pageId”],
“pageName”: hch[“pageName”],
“boolCheckBoxFields”: hch[“boolCheckBoxFields”],
“dateFields”: hch[“dateFields”],
“redirectUrl”: hch[“redirectUrl”],
“formInstanceId”: hch[“formInstanceId”],
“smartFields”:{},
“urlParams”:{},
“formValidity”:{},
“correlationId”: hch[“correlationId”],
“disableCookieSubmission”: hch[“disableCookieSubmission”]
}

var data = {
“email” : email,
“firstname” : firstname,
“lastname” : lastname,
“company” : company,
“page_id”: “4385066836”,
“portal_id”: 2236847,
“formId”: “a3e70050-52d3-4a8f-a891-18bc54aee8b5”,
“hs_context” : hs_context
}

jQuery.post(‘https://forms.hubspot.com/uploads/form/v2/2236847/a3e70050-52d3-4a8f-a891-18bc54aee8b5’, data, function(data, textStatus, jqXHR) {
}, ‘json’);

Thanks

0 Upvotes
parkeristyping
Member

API submission with conversion page recorded

Realizing after posting that this is describing the same problem I’m having.

Here’s my post, which includes some details: Landing page not tracking submission via Forms API

0 Upvotes