APIs & Integrations

okodoon
Member

Want to set inflow information to LP in original source.

In my code now, the original source is all judged to be via the API.

I want to register the inflow information to LP in the original source. What kind of structure should be used for that?

 

⬇︎my application action.

Frontend is React SPA. Backend API Service is Ruby on Rails.

 

1. Users come my LP by some method. (Advertise, Organic search, direct link, ...)

2. Move from LP to React SPA.

3. Users fill a signup form and submit form. handleSubmit method is called. this method send params to backend API.

4. In backend, create Hubspot::Contact and Hubspot::Company

5. handleSubmit method get return value from API.

6. Do `window._hsq.push(['identify', { email }])`

 

⬇︎my application code.

signup.tsx

handleSubmit = () => {
  axios
   .post(url, {form_params})
   .then(res => {
	if (window._hsq) {
        window._hsq.push(['identify', { email }])
    	  window._hsq.push(['trackPageView'])
      }
    })
}

users_api.rb

def signup
    user = User.create(user_params)

    hubspot_company = Hubspot::Company.create!(enterprise_account.name)

    hs_create_params = {
      firstname: user.name,
      company: enterprise_account.name,
      jobtitle: user.position,
      phone: enterprise_account.enterprise_phone_number,
      depertment: enterprise_account.department_name,
      adgroup: source_parameter ? source_parameter['utm_campaign'] : nil
    }
    hubspot_contact = Hubspot::Contact.create!(user.email, hs_create_params)
    hubspot_company.add_contact(hubspot_contact)
end

baseconnect-14 2.jpg

0 Upvotes
3 Replies 3
Willson
HubSpot Employee
HubSpot Employee

Want to set inflow information to LP in original source.

Hi @okodoon 


The recommendation if you're wanting to ensure the Original Source is set per the cookie values is the following:

Don't:

Do:

I hope this helps!

Product Manager @ HubSpot
0 Upvotes
okodoon
Member

Want to set inflow information to LP in original source.

Thank you for your reply.
You said, 
> Do:
  • Use either the trackPageView or trackEvent JavaScript functions after the identify function. These will pass a hutk cookie to the new contact record
But, I already do this in my code (Signup.tsx)
window._hsq.push(['identify', { email }])
window._hsq.push(['trackPageView'])

 Perhaps you misunderstand this question as not making a contact.

What I want to ask is

Instead of flowing into the application,
can the inflow to the LP that leads to the application be set to the original source of Contact?

0 Upvotes
Willson
HubSpot Employee
HubSpot Employee

Want to set inflow information to LP in original source.

Hi @okodoon 


Apologies for the radio silence on this one! I'm not sure if you were able to resolve this one or not but i'll jump back in just in-case. 

 

Looking at your clarifying question and reviewing the current process you're working with, my recommendation would be to scrap creating contacts via the Create Contacts / Create Company and instead work with the Forms API to create contacts. The reasoning for this is the ability to capture the and pass the cookie data via the hutk cookie.

 

When you're customers are landing on your LP from whichever source the originate from, we can capture this and store this in the cookie so that when this is passed as part of the submission process, we see the source correctly update to reflect the correct conversion path. 

 

You can see examples of how this is passed in our documentation here:

https://developers.hubspot.com/docs/methods/forms/submit_form_v3

 

We're specifically looking at the context parameter which details the following data:

  "context": {
    "hutk": ":hutk", // include this parameter and set it to the hubspotutk cookie value to enable cookie tracking on your submission
    "pageUri": "www.example.com/page",
    "pageName": "Example page"
  }

I hope this helps!

Product Manager @ HubSpot
0 Upvotes