Our users start on HubSpot, are transferred to our server for data processing, then sent back to HubSpot. Problem: HubSpot doesn’t receive most of the user’s data sent back.
The only data that is subsequently on HubSpot is the user’s email address and company - the rest, including the cookie data, disappears. It never shows up in the analytics.
The code’s that’s running on our server is given below.
Any idea what’s wrong?
thanks
Jon
The PHP code is:
// -------------- send user contact details to hubspot
$hubspotutk=’’;
if (isset($_COOKIE[‘hubspotutk’]) && $_COOKIE[‘hubspotutk’] == ‘yes’) {
$hubspotutk = $_COOKIE[‘hubspotutk’]; //grab the cookie from the visitors browser.
}
$ip_addr=’’;
if (isset($_SERVER[‘REMOTE_ADDR’]) && $_SERVER[‘REMOTE_ADDR’] == ‘yes’) {
$ip_addr = $_SERVER[‘REMOTE_ADDR’]; //IP address too.
}
$hs_context = array(
‘hutk’ => $hubspotutk,
‘ipAddress’ => $ip_addr,
‘pageUrl’ => ‘http://www.example.com/form-page’,
‘pageName’ => ’ Demo - with your PDF’
);
$hs_context_json = json_encode($hs_context);
$firstname='';
if (isset($_POST['firstname'])){
$firstname=$_POST['firstname'];
}
$lastname='';
if (isset($_POST['lastname'])){
$lastname=$_POST['lastname'];
}
$company='';
if (isset($_POST['company'])){
$company=$_POST['company'];
}
//Need to populate these variable with values from the form.
$str_post = "firstname=" . urlencode($firstname)
. "&lastname=" . urlencode($lastname)
. "&email=" . urlencode($emailTO)
. "&company=" . urlencode($company)
. "&hs_context=" . urlencode($hs_context_json); //Leave this one be
$portalId="1234567";
$formGuid="junk... contact me for details ";
//replace the values in this URL with your portal ID and your form GUID
//$endpoint = 'https://forms.hubspot.com/uploads/form/v2/{portalId}/{formGuid}';
$endpoint = 'https://forms.hubspot.com/uploads/form/v2/' . $portalId . '/' . $formGuid;
//echo "endpoint: " . $endpoint;
//send the info
$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);
//echo $status_code . " " . $response;
You can see I tried one from my home email last night
(<a class="moz-txt-link-abbreviated" href="mailto:jon2@highburyplace.co.uk">jon2@highburyplace.co.uk</a>)
Jon
Sorry - I assumed you could see the data on our account.
In the contact record it <u>only </u>shows the email address.
First name, last name and company are missing - as well as the
cookie details which would have included the initial page views.
Jon
Can you also send us a correct string that we can put into this
command
@curl_setopt($ch, CURLOPT_POSTFIELDS, $str_post);
- we can then find out whether the problem is at our end or yours.
thanks
Jon
Great progress! We can now see FirstName, LastName etc in the
Contacts.
(It was an inconsistent use of upper/lower case).
However we still can't track a Contact's journey through the HubSpot
site.
We see the pages they've gone to AFTER they've been onto our server
and returned to HubSpot.
But we don't capture anything that happened prior to that.
We had added the JavaScript code to our server code:
<!-- Start of HubSpot Embed Code -->
<script type="text/javascript" id="hs-script-loader"
async defer src="//js.hs-scripts.com/2432573.js"></script>
<!-- End of HubSpot Embed Code -->
Is there something else we need to do?
thanks
Jon
I see the page view history for AFTER the email address etc are
captured.
But it isn't linked to the page views for when the user first landed
on the HubSpot site.
So, for example, I have no idea which page the user originally
landed on.
I was expecting to see the earlier page views as part of the
timeline that you see after clicking on the Contact Name.
An example is attached.
For this example, I went to several pages on the HubSpot server,
then to our Demo server and back again.
You can only see the last set of page views.
We're not knowingly clearing anything on the HubSpot server or the
client machine.
Jon
@Jon That doesn’t seem right. When it comes to an issue in the product team our support team would probably know best. I would contact them and see if they know what is going on. You can reach them at help.hubspot.com or from within your portal. Please let me know if you get anywhere or if not so I can reach out to them if need be. Let me know if you run into anything else from an API standpoint.
@Jon Just so I understand after a user submits their email address to you, you send it over to hubspot. When a contact record is created you don’t see any of the page view history? A contact record won’t be created until we get an email address but you should see the existing page views that are all logged on the cookie on the machine. How are you testing this? Are you clearing any cookies?
Firstly, we use the variable name $emailTO earlier in the code.
The block you mention is just initialising the variables.
Before I do the checks you suggest, can you confirm that the
variable names (lastname, firstname, company) are correctly spelt
for what you expect at the HubSpot end?
Thanks
Jon
Zanran helps automate your PDF processing – especially content extraction. No other software starts with an understanding of the visual layout of each PDF page
I notice that you pass that variable in differently then the rest. The rest are all in this block. If you try and echo firstname or lastname before you make the curl request is it populated or blank?
$firstname=''; if (isset($_POST['firstname'])){ $firstname=$_POST['firstname']; } $lastname=''; if (isset($_POST['lastname'])){ $lastname=$_POST['lastname']; } $company=''; if (isset($_POST['company'])){ $company=$_POST['company']; }
@Jon I am not sure what you posted above. In the contact record on the Hubspot platform in your portal do you get all the information or just the email?