GTM Custom Events Not Attributing to Known Contacts

Hi everyone,

I’m trying to attribute custom events fired from GTM to the correct HubSpot contact records, but the events are consistently showing as “Unknown User” even when the user is already a known contact. I’ve already confirmed that my GTM tags are firing correctly and that the events are being received by HubSpot.

I’m hoping someone in the community might have a solution or a workaround for associating these events with the correct contact records.

Here is a quick overview of our user journey;

  1. User visit the website and clicks to get a quote
  2. User is redirected to our quote flow, where the Hubspot base tracking code and GTM container are loaded on application start.
  3. User enters an email address to log in or sign up
  4. User is sent a one-time verification code via email
  5. User enters the verification code and is authenticated.
  6. The “Quote Started” custom event tag is fired from GTM
  7. User answers questions and the “Quote Completed” custom event tag is fired from GTM
  8. A new contact and deal are created in Hubspot via an API call from our lead management system
  9. The user proceeds through the payment flow, and the “Payment Initiated” and "Purchase Completed" custom event tags are fired.

The challenge i’m facing is associating the early events (Step 6 & 7) with the contact record that is created in step 8.

Our main constraints are:

  • We cannot expose the user’s email address as a GTM variable due to security and privacy policies.
  • We have already tried using a hubspotutk variable, but the events still don’t seem to associate with the contact record because the events fire before the contact is created and officially identified.

Given these constraints, has anyone found a workaround or an alternative method to get these GTM events to associate with the correct contact record?

I’m open to any solutions or insights you might have.

Thanks,

David

Hi @DJohnson4,

From what I know (someone can correct me if I am wrong), custom events cannot be retroactively associated with a contact once the events are recorded in HubSpot. The contact has to exist first and then custom events (including the ones that happened in the past) can be added to the contact record. Page views and sessions are the exception that the tracking code handles.

Based on your flow, ideally you would create a contact record in step 3 (when user enters the email to log in or sign up) that the events could be pushed to.

If that is not possible, assuming you can pass info from GTM to your lead management system, I would consider having fields in your lead management system that would store timestamps of those GTM events. Then, after you create the contact via the API, you could either use the now known record ID or email try to create those custom events via API as well, along with the timestamp data to indicate when those events happened.

Hope this helps!