Want to know which page the user came from

SOLVE
Highlighted
New Contributor

We want to get information about the pages that the user has gone through before signing up for our service.

User came from the ad? User came from direct search? I want to know.

 

スクリーンショット 2020-01-08 16.06.35.png

 

⬇︎this is my code. and user's action.

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

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

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

3. handleSubmit method get return value from API and do `window._hsq.push(['identify', { email }])`, `window._hsq.push(['trackPageView'])

 

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

We believe that the user's cookie information will be linked to contact by executing  `window._hsq.push(['identify', { email }])`

But I can't get cookie information before signup.

How should I do. Please help me.

Reply
0 Upvotes
1 Accepted solution

Accepted Solutions
Community Manager

Hey @okodoon ,

 

The primary way that this info is tracked on a HubSpot contact record is the Original Source properties. These populate with specific sources based on a number of criteria, including "Paid Search," "Social Media," and "Offline Sources."  Assuming that the identification is working correctly, HubSpot tracking cookie should include the contact's original source information automatically.

 

Without any specific example(s), it's difficult to say with any certainty why you're not seeing page view info from before the contact converted. Any of the following might be contributing:

  • You don't have cross domain tracking set up properly
  • IP filtering is impacting your in-office testing
  • The tracking code isn't set up properly accross your site, or it's not configured properly for a single page application
  • Some or all of the contact(s) in question started the session by navigating directly to your app

I believe the most likely issue out of the above is that there's something wrong with your cross domain tracking. Since the tracking cookie is domain-specific, it's important to set up cross domain tracking in your account if your website is spread accross multiple domains (e.g. www.mysite.com and app.myapp.com). Here's some information on cross domain tracking, for reference: https://knowledge.hubspot.com/reports/set-up-your-site-domains#set-your-target-domain

 

Whether or not that's the issue, I'm happy to dig in further if you can provide some more detail. Specifically, an example contact that's missing relevant information, and the page/form you're working with (so that I can run my own tests).

 

Outside of all of that, it's possible to simplify the process you're describing: If you were to use the Form Submission API. This endpoint has two specific pieces of functionality that can help optomize your process:

  • First, this endpoint allows for CORS request made from the frontend, so you can submit contact information directly to HubSpot.
  • Second, this endpoint accepts a hubspotutk field, which is the HubSpot tracking cookie. Including this parameter is functionaly the same as calling the identify method of the tracking code API

 

Reply
0 Upvotes
1 Reply 1
Community Manager

Hey @okodoon ,

 

The primary way that this info is tracked on a HubSpot contact record is the Original Source properties. These populate with specific sources based on a number of criteria, including "Paid Search," "Social Media," and "Offline Sources."  Assuming that the identification is working correctly, HubSpot tracking cookie should include the contact's original source information automatically.

 

Without any specific example(s), it's difficult to say with any certainty why you're not seeing page view info from before the contact converted. Any of the following might be contributing:

  • You don't have cross domain tracking set up properly
  • IP filtering is impacting your in-office testing
  • The tracking code isn't set up properly accross your site, or it's not configured properly for a single page application
  • Some or all of the contact(s) in question started the session by navigating directly to your app

I believe the most likely issue out of the above is that there's something wrong with your cross domain tracking. Since the tracking cookie is domain-specific, it's important to set up cross domain tracking in your account if your website is spread accross multiple domains (e.g. www.mysite.com and app.myapp.com). Here's some information on cross domain tracking, for reference: https://knowledge.hubspot.com/reports/set-up-your-site-domains#set-your-target-domain

 

Whether or not that's the issue, I'm happy to dig in further if you can provide some more detail. Specifically, an example contact that's missing relevant information, and the page/form you're working with (so that I can run my own tests).

 

Outside of all of that, it's possible to simplify the process you're describing: If you were to use the Form Submission API. This endpoint has two specific pieces of functionality that can help optomize your process:

  • First, this endpoint allows for CORS request made from the frontend, so you can submit contact information directly to HubSpot.
  • Second, this endpoint accepts a hubspotutk field, which is the HubSpot tracking cookie. Including this parameter is functionaly the same as calling the identify method of the tracking code API

 

Reply
0 Upvotes