Connecting Google Analytics and Hubspot

Highlighted
New Contributor

Hi everyone,

We want to set up end-to-end analytics for our website and connect it with our Hubspot CRM. So that we can track from what campaign a lead came from.

To do this, we need to transfer the CID (customer ID) from the cookie to the CRM Hubspot, and the CID should be attached to the card of a lead. We need to transfer it to Google Analytics using the API Measurement Protocol. How can you implement this solution?

 

Does Hubspot API give an ability to do this? What endpoint should we use?

What are the other recommendations to accomplish this task?

 

Thanks.

Reply
0 Upvotes
3 Replies 3
Community Manager

Hey @idunskiy ,

 

Happy to help here, but to start can you give me some more context on the specifics of what you're trying to push to HubSpot? Are you just looking to send the CID into a contact property? 

 

From the frontend, the Tracking Code API has some methods (namely, identify) that allow you to identify visitors as existing contacts & send values for contact properties. You can also trigger custom events, if you have an Enterprise subscription. Is that what you're looking to do?

New Contributor

Hey @Derek_Gervais , 

 

Yes, CID would be enough at the moment. How can I implement it?

Reply
0 Upvotes
Community Manager

Hey @idunskiy ,

 

The only way to trigger a contact property update using the Tracking Code API is to use the Identify method, documented here. Using the Identify method, you can pass data into contact properties; here's a simple example:

var _hsq = window._hsq = window._hsq || [];
_hsq.push(["identify",{
    email: getParameterByName("email"),
    favorite_color: 'orange'
}]);

Some notes here:

  • Because HubSpot contact records require an email address, the Identify method alos requires an email address.
  • The identification data will only be passed when tracking a pageview or an event (with either the trackPageView or trackEvent functions).
Reply
0 Upvotes