Tracking Contact Website Activity via API

contacts

#1

I’m currently integrating HubSpot in a web platform built completely outside their web tools. I can’t seem to wrap my head around how to track a contact’s website activity from our web platform.

We already have the HubSpot tracking code embedded at the bottom of each of our platform’s pages:
<script type="text/javascript" id="hs-script-loader" async defer src="//js.hs-scripts.com/2*****4.js"></script> yet under each contact we know is using the website Website Activity says “No data is available for this contact”.

Can anyone shine some light on this integration?

Thanks.


#2

Hi @wwwroth,

Just to make sure that we’re on the same page, are you not seeing this visit information on the contact’s timeline in HubSpot? There are a few reasons why the visit info for a contact might be missing, but the most likely is that the contact in your portal isn’t yet associated with the hubspotutk cookie that is tied to their visit information. This is often the case for contact records created via import or offline sources; because they were created that way, the visitor information gather from their website activity hasn’t yet been associated with their contact record (usually via form submission).

It’s also possible that your target domain settings are incorrect, per this Knowledge Base article:


#3

Hi @Derek_Gervais,

Thanks for your reply. I’ve verified my target domain is correct, so I think it has to do with the hubspotutk cookie. When viewing a contact, I’m not seeing anything under “Website Activity”. I’d like to see pages they’ve viewed on the site.

Currently, when a user creates an account on our website, I generate a new contact in HubSpot via /contacts/v1/contact. It seems to be defaulting to ‘created from offline sources’. I was under the impression the js tracking code would “automagically” start tracking their activity on the website and associate it with the created contact record but that doesn’t seem to be the case.

Can you send me over some information on tracking page views and web activity via hubspotutk?


#4

Hi @wwwroth,

Creating contacts via the contacts API (/contacts/v1/contact) doesn’t include any tracking/identification information. You might want to consider using the forms API or tracking code API instead, which are both capable of creating contacts & including their tracking information: