APIs & Integrations

jesseniem
Member

Conversion tracking with the Forms API

Hi,

I’ve been working with the Forms API for a while and for the most part everything works just fine as the submissions appear correctly in HubSpot with the correct field values.

However, all of the stuff related to “web analytics” doesn’t work. For example, the original source is shown as “Offline sources” with the drill down saying “FORM”, even though I came to the site via a link and can verify that the cookie value of the user is correctly being passed in the hutk section as part of the request body.

I assume the issue might have something to do with my escaping/formatting of “hs_context” part being somehow incorrect. Any ideas on what could be wrong? You’ll find an example request body below.

city=Unknown&firstname=Test&lastname=User&company=Test&lead_source=app&hs_context=%257B%2522pageName%2522%253A%2B%2522Viima%2BApp%2BSignup%2522%252C%2B%2522pageUrl%2522%253A%2B%2522http%253A%252F%252Flocalhost%253A8000%252Fsignup%2522%252C%2B%2522ipAddress%2522%253A%2B%2522127.0.0.1%2522%252C%2B%2522hutk%2522%253A%2B%2522ec8ea7f193fc11654bf32a5fd35cbd95%2522%257D&country=Unknown&lifecyclestage=customer&email=test%40test.com

14 Replies 14
tchin
Member

Conversion tracking with the Forms API

When I turn off IP Filtering (remove my IP from the excluded list) - is it immediate or is there a wait until I start to see Analytics data come in?

0 Upvotes
Dadams
HubSpot Employee
HubSpot Employee

Conversion tracking with the Forms API

The IP filter is applied when the analytics is processed, so removing an IP will not reprocess the existing data, it would just start showing data from that IP going forward. The same applies in reverse as well, adding a new IP will not filter out past traffic, jut new traffic going forward. The IP filter gets applied within a minute, but analytics also has a processing delay of a few minutes so you may not see the effects for several minutes.

0 Upvotes
tchin
Member

Conversion tracking with the Forms API

Awsome! Thanks again!

0 Upvotes
tchin
Member

Conversion tracking with the Forms API

0 Upvotes
tchin
Member

Conversion tracking with the Forms API

I think this is working OK. Because I am testing multiple users on one PC/Browser, it looks like the Analytics is tracking based on one unique cookie. So most of the analytics data is being tracked as expected, just to one particular user. If I clear my cookies Hubspot tracking should recognize me as a ‘new’ user.

Thanks for your help.

T

0 Upvotes
Dadams
HubSpot Employee
HubSpot Employee

Conversion tracking with the Forms API

Thanks @tchin, looking at that record, I can see that the form submission looks ok, and the utk is getting attached to the contact, but the utk does not show any analytics data, so it doesn’t look like there are any page views to show. So the form submission is working correctly, but the page views are not being tracked.

Is this set up on a local testing system, or would there be a way for me to take a look at the pages you’re testing this with?

0 Upvotes
tchin
Member

Conversion tracking with the Forms API

How do I share that contact record? I can only see it if I am logged in. Also, the response from the Forms API endpoint is empty. It doesn’t fail, just empty. But the record did get created.

0 Upvotes
Dadams
HubSpot Employee
HubSpot Employee

Conversion tracking with the Forms API

Form submissions return a 204 no content response, so you will get a response with that status code, but there won’t be anything in the body of the response.

For sending me the contact, you can either just send me a link to the record you’re viewing, or just send me your Hub ID and the contact vid or email.

0 Upvotes
tchin
Member

Conversion tracking with the Forms API

I am having a similar issue where I am not seeing any Hubspot Analytics data. I am submitting the hs_context data via Forms API on my external site (using PHP to cURL the data to the endpoint). I created a form in hubspot so that I would have a form guid needed to post the form data. I am not embedding the hubspot form but using my own form.

I have taken the following steps -

  1. Installed Hubspot tracking cookie script on all pages of our website. Double-checked to make sure cookie is present
  2. Correctly encoded my hs_context values - {“hutk”:“xxxcxxxxxx39e1c987107008xxx”,“ipAddress”:“xxx.xxx.x.xxx”,“pageUrl”:“https://www.example.com/signup/",“pageName”:"Sign up for a plan”} (masked hutk and ip values for this thread)
  3. Removed my IP address from the IP Filtering list

When I submit the form it correctly populates name, email, company etc. But I am not seeing any analytics data being populated. For example, under Forms, the submissions are incrementing with each submit but the views are still at 0. In the individual contact settings properties, the IP Address is being correctly set, but nothing for IP City, State etc. Also page views is still at 0. I should note that my page is not public facing (my ip is private). Could this be affecting the analytics data not populating? I looked for this extensively but did not find any information in the Hubspot documents that says this would be an issue.

Thanks!

0 Upvotes
Dadams
HubSpot Employee
HubSpot Employee

Conversion tracking with the Forms API

@tchin If you’re using the Forms API to send HubSpot form data, we’ll record submissions but we don’t have a way to record form views. At the moment we’ll only record views to the form if you’re using the form embed code.

For the contact record, the analytics data won’t populate immediately, so if you’re looking for views and page views for the record immediately after its creation, you’ll need to wait a minute or so to see the analytics data populated.

If you’ve waited a while and you’re still not seeing that, then there might be a problem with the submission. Do you have an example of the full encoded POST data you’re using? Even if the JSON in hs_context is correctly encoded there might be another issue with that data.

0 Upvotes
tchin
Member

Conversion tracking with the Forms API

Here is the fully encoded POST data I am sending -

&firstname=sprintsignup&lastname=test11&dev_testing=YES&email=developer-mb%2Bsprintsignuptest11%40dev.app.emailonacid.com&hs_context=%7B%22hutk%22%3A%22c34d8ca17a28539e1c987107008876df%22%2C%22ipAddress%22%3A%22192.168.1.106%22%2C%22pageUrl%22%3A%22https%3A%5C%2F%5C%2Fwww.eoadev.com%5C%2Fsignup%5C%2F%22%2C%22pageName%22%3A%22Sign+up+for+a+plan%22%7D

And the array before I run http_build_query() -

Array
(
[firstname] => sprintsignup
[lastname] => test11
[dev_testing] => YES
[email] => developer-mb+sprintsignuptest11@dev.app.emailonacid.com
[hs_context] => {“hutk”:“c34d8ca17a28539e1c987107008876df”,“ipAddress”:“xxx.168.1.xxx”,“pageUrl”:“https://www.eoadev.com/signup/",“pageName”:"Sign up for a plan”}
)

I gave it 48 hours but still no analytics data.

Thanks!

0 Upvotes
Dadams
HubSpot Employee
HubSpot Employee

Conversion tracking with the Forms API

The data looks ok, can you send me a link to the contact record that that submission created?

0 Upvotes
jesseniem
Member

Conversion tracking with the Forms API

Thanks for the quick reply @dadams! :slight_smile: That would indeed seem to have been the issue.

The requests library in Python can’t handle dictionaries inside a dictionary so doing the URL escaping manually resulted in this behaviour.

If someone else is trying to do this with python, you can use json.dumps() to convert the hs_context dictionary to a JSON string for the request library to process automatically.

Dadams
HubSpot Employee
HubSpot Employee

Conversion tracking with the Forms API

Hi @jesseniem

The hs_context data is getting double encoded. When you decode the value in that example, the result is still URL encoded:

%7B%22pageName%22%3A+%22Viima+App+Signup%22%2C+%22pageUrl%22%3A+%22http%3A%2F%2Flocalhost%3A8000%2Fsignup%22%2C+%22ipAddress%22%3A+%22127.0.0.1%22%2C+%22hutk%22%3A+%22ec8ea7f193fc11654bf32a5fd35cbd95%22%7D

That value is what you’d actually want in the POST data, since decoding that gets you the valid JSON.

{“pageName”:+“Viima+App+Signup”,+“pageUrl”:+“http://localhost:8000/signup",+“ipAddress”:+“127.0.0.1”,+“hutk”:+"ec8ea7f193fc11654bf32a5fd35cbd95”}

0 Upvotes