Getting Form Submission Data and Analytics using Forms API


#1

Hi there,

I have followed the Forms API instructions but still haven’t found a solution to this issue, so any help would be greatly appreciated.

I have a custom HTML form on a hubspot page that sends the info to our server in an AJAX call, and on success I send the required contact info (not password) to the Hubspot Forms API, on another hubspot form I created.

I can see the submissions on that form(hubspot), but on the hubspot page with the original custom form, the submissions don’t get recorded and I obviously don’t get any other analytics (except for views).

I was just wondering how to configure this (using the Forms API), so I can get the submission data to show on the page where the custom form is?


#2

Just to add clarification, this is the view data on the page with the custom form.

So after a user registers using the form on this page, the form submission is only showing on the hubspot form I created, and the submissions aren’t coming to the custom form on this page. Is there a way to link them?


#3

Hi @BigMac,

What values are you including in the hs_context parameter when submitting the form?


#4

Hi @Derek_Gervais,

here is what I am putting in the hs_context:

'hs_context': JSON.stringify({
                                "hutk": getCookie('hubspotutk') || '',
                                "ipAddress": "{{ request.remote_ip|string }}",
                                "pageUrl": window.location.href,
                                "pageName": document.title
                            }) 

the getCookie function I am using for the hutk is:

 function getCookie(name) {
            var cookieValue = null;
            if (document.cookie && document.cookie !== '') {
                var cookies = document.cookie.split(';');
                for (var i = 0; i < cookies.length; i++) {
                    var cookie = jQuery.trim(cookies[i]);
                    // Does this cookie string begin with the name we want?
                    if (cookie.substring(0, name.length + 1) == (name + '=')) {
                        cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                        break;
                    }
                }
            }
            return cookieValue;
    }

#5

Hi @BigMac,

Sorry for the lengthy delay on this; the topic slipped under my radar. That specific form submissions number looks for a pageId value in the hs_context field. The pageId is the internal identifier for HubSpot landing/website pages. You can find this ID in the URL when viewing a page’s details in HubSpot.


#7

Thanks Derek, it didn't work right away, but does seem to be working now on our analytics page (after a few hours).