We currently have a custom form that communicate with our backend server for users to download our software, since it is custom coded we are not accurately tracking where our users are coming from and the conversion rate of each traffic channel.
Looking at the form on our site, I see that it's calling a .php document with this code snippet:
// May 2016 - Post Free Downloads leads to HubSpot too
$hs_form_id = "317069ee-049f-4db1-9934-20311bef48a1";
// $hs_pageUrl = "http://www.rti.com/downloads/index.html";
$hs_pageUrl = "https://www.rti.com/free-trial";
$hs_pageName = "RTI Free Downloads Application";
...
$result = post_to_hubspot($hs_form_id, $clean_post, $hs_pageUrl,
$hs_pageName);
where post_to_hubspot is an additional .php form for additional code:
<?php
indent preformatted text by 4 spaces
/**`Preformatted text`
* Submit form data to HubSpot
*
* Process a new form submission in HubSpot in order to create a new Contact.
* http://developers.hubspot.com/docs/methods/forms/submit_form
*/
function post_to_hubspot2($formId, $params, $hs_pageUrl = null, $hs_pageName = null) {
//grab cookie from browser
if (isset($_COOKIE['hubspotutk'])) {
$hubspotutk = $_COOKIE['hubspotutk'];
} else {
$hubspotutk = "";
}
$ip_addr = $_SERVER['REMOTE_ADDR']; // log IP address too.
$hs_context = array(
'hutk' => $hubspotutk,
'ipAddress' => $ip_addr,
'pageUrl': "https://www.rti.com/free-trial",
'pageName': "Download RTI Connext DDS Professional",
);
// Two optional parameters
if (!empty($hs_pageUrl)) {
$hs_context['pageUrl'] = $hs_pageUrl;
}
if (!empty($hs_pageName)) {
$hs_context['pageName'] = $hs_pageName;
}
$hs_context_json = json_encode($hs_context);
//Need to populate these varilables with values from the form.
$str_post = http_build_query($params);
$str_post .= "&hs_context=" . urlencode($hs_context_json); //Leave this one be
//replace the values in this URL with your portal ID and your form GUID
$endpoint = 'https://forms.hubspot.com/uploads/form/v2/1754418/' . $formId;
// error_log("Posting to form $formId with added data " . print_r($hs_context, true), 0);
error_log("curl " . $endpoint . $formId . "?" . $str_post, 0);
$ch = @curl_init();
@curl_setopt($ch, CURLOPT_POST, true);
@curl_setopt($ch, CURLOPT_POSTFIELDS, $str_post);
@curl_setopt($ch, CURLOPT_URL, $endpoint);
@curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/x-www-form-urlencoded'
));
@curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = @curl_exec($ch); //Log the response from HubSpot as needed.
$status_code = @curl_getinfo($ch, CURLINFO_HTTP_CODE); //Log the response status code
@curl_close($ch);
return($status_code);
}
// vim: expandtab sw=4 tabstop=4 softtabstop=4
?>
As of right now, we are getting the # of downloads and contact information. However we are not getting conversion rate for all pageviews, or conversion rate for each of the traffic channel.
Any insights on what we are currently missing on the code snippets posted above is greatly appreciated.
Hi @dtran, correct - form views vs page views are not calculated in the same manner. Form views are calculated when a pixel in the embedded form is loaded. Page views are much more complex in nature and are thus not used or available when looking at Form Submission rate.
Hi @dtran, the reason is because, as Isaac mentions in that thread I linked above, the form views metric is only tracked when a HubSpot form embed code is fired. On the backend we then calculate the submission rate as: (submissions ÷ views) * 100.
Since views would be empty, we cannot calculate this accurately and cannot rely on browser sessions due to a number of things like bot activity, how we calculate sessions instead of page views etc. The pixel that fires when a form is loaded is quantifiable on the backend and we can use that to calculate the conversion rate, but we can't do the same with the tracking code
Currently we have create a Hubspot form and it seems that we are pushing the correct Contact information to our system but we are lacking information such as pageview, conversion rate, # of new customers, submission per traffic channel etc...
However, it's being registered as an Unidentified form on Hubspot. Based on the article it seems that we can clone this to Hubspot. Since I have created a similar form on Hubspot since 2016, is there any way for me to link this unidentified form to an existing Hubspot form?
Hi @drtan since that form is a non-HubSpot form, you won't get any tracking on conversion rate etc. In my last response:
this metric is only tracked when a HubSpot form embed code is fired, so submissions made through the API does not affect it.
You can always rename that form if you'd like, though! Just hover over the form, then click Actions > Rename.
To make the form data not be grouped together, I'd recommend replacing them with native HubSpot forms and embedding them on your external page. That way, you'd get conversion rate as well.
Unfortunately since this form connects with our backend server, we cannot use a native Hubspot form. I have contacted one of our Hubspot account manager and the recommended approach was to use the form tracking API as mentioned.
I'm a little confused why it's unable to track conversion rate though. If we have pageview and submission data, wouldn't it be simple to get conversion?