We are evaluating Segment -> Hubspot integration. Specifically, we want to track Anonymous user activities and send it to hubspot and then tie in those activities to contacts ONCE an `identify` is called in our site.
We tried it with Hubspot Web Actions and works properly. We see that behaviors and activities are sent to hubspot for anonymous users with no contacts and once we do an `identify` - hubspot updates the events to tie in with the contact.
The issue we found with Web Actions is that we need to manually clear the hubspot user token and some other cookie values whenever our user logs out to have a new values for those. Looks like analytics.js `reset()` does not clear those values.
We also tried using Cloud Actions but it looks like it cannot tie in anonymous user events with contacts once they logged-in? It would have been convinient to use Cloud Actions with Segment anonymous ID if possible.
So for our question:
1. Is ther a way for analytics.js reset() to also clear the relevant Hubspot cookie values so we get a new hubspot user token on user log-out.
2. Is there a way to tie in anonymous user activities to contacts in Hubspot using cloud actions? Possibly using Segment's anonymousId field as the source of the anonymous user tracking and upserting a contact using the anonymous ID when we got a login-in?
Hi @Devlevar1 , you’re basically bumping into the fact that HubSpot’s “retroactive stitch” relies on the browser visitor identity (the HubSpot tracking cookie), not Segment’s anonymousId.On (1): Segment’s analytics.reset() only resets Segment’s own identifiers. It won’t clear HubSpot’s cookies, so HubSpot will keep the same visitor token across sessions unless you explicitly delete HubSpot’s tracking cookies on logout (most importantly hubspotutk, plus the session cookies like __hssc / __hssrc). HubSpot documents the cookies it sets and what they do here: https://knowledge.hubspot.com/privacy-and-consent/what-cookies-does-hubspot-set-in-a-visitor-s-brows...
One question: do you actually want logout to create a brand new “anonymous visitor” in HubSpot every time (it can change attribution and has privacy implications), or are you trying to prevent cross-user leakage on shared devices?
On (2): Cloud Actions won’t stitch anonymous web activity
the same way because those events are server-side from HubSpot’s point of view. Unless you pass HubSpot’s visitor context (the hutk / hubspotutk value) along with the event, HubSpot has nothing to merge with when an identify happens later. That’s why Web Actions “just work” for anonymous behavior: they’re running in the browser with the tracking context.
If you want to stay mostly cloud-mode, the usual pattern is: capture hubspotutk client-side, send it into Segment as an event/context field, and then have your server-side calls to HubSpot include that same visitor token when tracking events via the Tracking Code API (trackEvent / identify). HubSpot’s tracking methods are outlined here: https://developers.hubspot.com/docs/api-reference/legacy/tracking-code-v1/overview.
Hope this helps clarify why you’re seeing the difference, and where the stitching is really coming from.
Did my answer help? Please mark it as a solution to help others find it too.
Ruben Burdin HubSpot Advisor Founder @ Stacksync Real-Time Data Sync between any CRM and Database
Hi @Devlevar1 , you’re basically bumping into the fact that HubSpot’s “retroactive stitch” relies on the browser visitor identity (the HubSpot tracking cookie), not Segment’s anonymousId.On (1): Segment’s analytics.reset() only resets Segment’s own identifiers. It won’t clear HubSpot’s cookies, so HubSpot will keep the same visitor token across sessions unless you explicitly delete HubSpot’s tracking cookies on logout (most importantly hubspotutk, plus the session cookies like __hssc / __hssrc). HubSpot documents the cookies it sets and what they do here: https://knowledge.hubspot.com/privacy-and-consent/what-cookies-does-hubspot-set-in-a-visitor-s-brows...
One question: do you actually want logout to create a brand new “anonymous visitor” in HubSpot every time (it can change attribution and has privacy implications), or are you trying to prevent cross-user leakage on shared devices?
On (2): Cloud Actions won’t stitch anonymous web activity
the same way because those events are server-side from HubSpot’s point of view. Unless you pass HubSpot’s visitor context (the hutk / hubspotutk value) along with the event, HubSpot has nothing to merge with when an identify happens later. That’s why Web Actions “just work” for anonymous behavior: they’re running in the browser with the tracking context.
If you want to stay mostly cloud-mode, the usual pattern is: capture hubspotutk client-side, send it into Segment as an event/context field, and then have your server-side calls to HubSpot include that same visitor token when tracking events via the Tracking Code API (trackEvent / identify). HubSpot’s tracking methods are outlined here: https://developers.hubspot.com/docs/api-reference/legacy/tracking-code-v1/overview.
Hope this helps clarify why you’re seeing the difference, and where the stitching is really coming from.
Did my answer help? Please mark it as a solution to help others find it too.
Ruben Burdin HubSpot Advisor Founder @ Stacksync Real-Time Data Sync between any CRM and Database
One question: do you actually want logout to create a brand new “anonymous visitor” in HubSpot every time (it can change attribution and has privacy implications), or are you trying to prevent cross-user leakage on shared devices?
For now yes, we noticed that logging out of our app it still continues to attribute views to the logged-out user and that cookie seems to last for a long time (6 mos).
If you want to stay mostly cloud-mode, the usual pattern is: capture hubspotutk client-side, send it into Segment as an event/context field, and then have your server-side calls to HubSpot include that same visitor token when tracking events via the Tracking Code API (trackEvent / identify). HubSpot’s tracking methods are outlined here: https://developers.hubspot.com/docs/api-reference/legacy/tracking-code-v1/overview.
Is there an option in Segment Hubspot Cloud Action to do that? I can't find an option to send data to the tracking API there.