Recently while working on one of our project we came across requirement where we wanted Hubspot integration with our application for ease of sales team to manage user's data and understand their interactions and trends in application. I will quickly explain few things about Hubspot here in my article.
What is Hubspot?
In brief, Hubspot is a CRM which helps you monitor and fine tune many things regarding your application. Based on my analysis I will shortly list down few most important of them in order to give you more insights about it -
- Closely monitoring user interactions with your application.
- To find out users who should be assisted by some campaign.
- Pattern of product purchase by user.
- Setup workflows, campaigns and send emails to users.
- Get analytical data about page views, user visits and user location.
You can read more about it here - Hubspot CRM
In order to get benefit of these features of Hubspot you need to have Hubspot account and further you can consume their API to integrate it with your application in order to automate user data collection and many other things in Hubspot.
Benefits of just having Hubspot account?
- You can have user data stored in terms of Contacts in Hubspot and perform any operations on that data by setting up some workflows which will trigger some action on change in those contacts data.
- You can include Hubspot page views tracking script in your application pages in order to have page views and count recorded in Hubspot when user visits those pages. You just need to embed your Hubspot ID at given place in that script and that script automatically reports data to your Hubspot account whenever respective pages are loaded -
Hubspot page views tracking code
Hubspot Integration and How to implement?
You can also integrate Hubspot with your application for more automation by consuming API exposed by Hubspot. In following link you will get options for reading Hubspot API documentation and option to create Hubspot Developer account as you will need one developer account in order to test Hubspot integration in developement mode - https://developers.hubspot.com/
-
You can create Hubspot developer account which will be separate from your production Hubspot account. Once you create that, you need to create test portal inside it one per environment of your application eg. Development, Staging etc.
You don't need to create one for production as you might be already having that ready. Each portal has it's own Hubspot ID in top right corner and API key (which can be created/found by going in Integrations section from top right dropdown) -
By having above setup ready you can integrate your application with Hubspot using
API key
andHubspot ID
of your Hubspot portal. In Rails application you can configure it in your application based on environment in yml file as follows -
development: &development
portal_id: *******
hapikey: *******
form_a_guid: *********
form_b_guid: *********
form_c_guid: *********
-
Once you have your required Hubspot credentials configured in your application you can write your own service to consume Hubspot API - Hubspot API
I did use gem Hubspot Ruby I found good enough for my purpose but the only thing in case of this gem is, it is still improving and has little documentation for some most imprortant Hubspot API methods, so sometime you may need to search for additional API methods by digging inside gem files. But yes by doing this you can also contribute to it for documentation or improvements if you feel so. -
Once you write your service or include gem for accessing Hubspot API, you are all set to start reading and writing to your Hubspot portal data.
-
You can also make use of Hubspot forms API to submit form data from your application to forms created in Hubspot portal to track form submissions. For example through this you can create Contact for user when he/she signups in your application and also send his/her analytical details like IP Address and Hubspot Cookie (Stored automatically in user's browser as
hubspotutk
when you have hubspot tracking script loaded on your application page) along with form params to Hubspot. -
If you pass cookie mentioned in above point to Hubspot, it will help Hubspot to show analytical details for each Contact on its timeline (Page views, Last visited Page, way through which that contact came to your site first etc.)
To access forms created in your Hubspot portal you need to have their guid stored in your application. Please refer Hubspot config mentioned above in point #2 .
To pass cookie and ip address along with form params, make sure you convert it to json blob as follows (in rails way) before adding them to form params otherwise it won't work as expected.hs_context = { "hs_context" => { "hutk" => "efef144333", "ipAddress" => "0.0.0.0" }.to_json }
form_params_hash.merge!(hs_context)
So that's all about extract of Hubspot. There are lot many details which you can get by reading their documentation but by knowing above things I hope you should be clear enough to start with Hubspot integration for your application and start using it.
For any questions and details you can visit and/or post queries in Hubspot Developer Forum .
Thank you :)