Data Hub

FMay
Participant

Getting value from browser when executing workflow

SOLVE

I am pretty new to Hubspot but have a couple of workflows working. This one has defeated me though.

 

I have added Amplitude tracking in Hubspot. This generates an ID to uniquely identify the user in the CMS. This ID is generated and sent to Amplitude while the user is anonymous. This works fine.

 

When a new contact is added, I think I need to execute a workflow in order to call my backend. Using this approach I know the Contact ID but I don't know how to access the Amplitude ID, as it is only available via a function call in the browser.

 

Is there a simple strategy I am missing here? Hope it's clear enough.

 

Thanks

 

Freddy

1 Accepted solution
RubenBurdin
Solution
Top Contributor

Getting value from browser when executing workflow

SOLVE

Hi @FMay 

That’s a clever workaround with localStorage, nice thinking.

 

The key limitation you hit is that workflows in HubSpot run server-side, with no access to browser context or JavaScript variables. So you can’t “pull” a value like the Amplitude user ID into a workflow unless it’s first stored in a HubSpot property.

 

The cleanest native approach is still to capture the Amplitude ID client-side and push it into a hidden field in your HubSpot form before submission (https://knowledge.hubspot.com/forms/create-and-edit-forms )

 

 That way, it becomes part of the contact record and is available for workflows, APIs, or any backend process. If your setup relies on custom events instead of forms, you could also use the HubSpot Forms API or Tracking Code API to send the ID programmatically 

 

If your goal later expands to syncing this identifier across Amplitude, HubSpot, and your backend in real time, a two-way sync layer can help. It keeps contact and event IDs consistent across all systems without relying on browser scripts. Stacksync handles this type of cross-system alignment automatically so user tracking stays coherent end-to-end.

Did my answer help? Please mark it as a solution to help others find it too.

Ruben Burdin Ruben Burdin
HubSpot Advisor
Founder @ Stacksync
Real-Time Data Sync between any CRM and Database
Stacksync Banner

View solution in original post

0 Upvotes
4 Replies 4
RubenBurdin
Solution
Top Contributor

Getting value from browser when executing workflow

SOLVE

Hi @FMay 

That’s a clever workaround with localStorage, nice thinking.

 

The key limitation you hit is that workflows in HubSpot run server-side, with no access to browser context or JavaScript variables. So you can’t “pull” a value like the Amplitude user ID into a workflow unless it’s first stored in a HubSpot property.

 

The cleanest native approach is still to capture the Amplitude ID client-side and push it into a hidden field in your HubSpot form before submission (https://knowledge.hubspot.com/forms/create-and-edit-forms )

 

 That way, it becomes part of the contact record and is available for workflows, APIs, or any backend process. If your setup relies on custom events instead of forms, you could also use the HubSpot Forms API or Tracking Code API to send the ID programmatically 

 

If your goal later expands to syncing this identifier across Amplitude, HubSpot, and your backend in real time, a two-way sync layer can help. It keeps contact and event IDs consistent across all systems without relying on browser scripts. Stacksync handles this type of cross-system alignment automatically so user tracking stays coherent end-to-end.

Did my answer help? Please mark it as a solution to help others find it too.

Ruben Burdin Ruben Burdin
HubSpot Advisor
Founder @ Stacksync
Real-Time Data Sync between any CRM and Database
Stacksync Banner
0 Upvotes
TomM2
Thought Leader | Platinum Partner
Thought Leader | Platinum Partner

Getting value from browser when executing workflow

SOLVE

Hey @FMay HubSpot doesn't "connect" to a visitors browser, meaning there's no way to retroactively have a system go back to the browser and grab more data. When a form is submit by a contact the form simply sends a cookie with the tracking information to HubSpot and it processes the analytics tracking. Data outside this isn't captured, it would need to be sent to HubSpot or another storage system at some point in order to be captured. 

One thing you could do is add a hidden field to your HubSpot form to store the amplitude ID for the contact in. 

 

You would then however need a script to grab the amplitude ID and pass it to that hidden form field, this would require some custom JS development. There's some guides on passing values to fields via JS. There's another post about how to set a value with custom JS available here

However you'll need something to actually capture the value itself from amplitude. 

 

There's also a pre-built Amplitude HubSpot integration which might be useful to you! https://ecosystem.hubspot.com/marketplace/apps/marketing/analytics-data/amplitude-engage

 

The only other option would be to create a script that automatically stores the amplitude information somewhere you always have access to, you'll then need to call that data through a webhook or custom code within your workflow. 

Tom Mahon
Technical Consultant | Solutions Engineer | Community Champion
Baskey Digitial

Book a consultation

Did my post help answer your query? Help the community (and me) by marking it as a solution.


FMay
Participant

Getting value from browser when executing workflow

SOLVE

Thanks Tom. All very useful information.

 

In the end I solved the problem by including a script in the footer that checks if I have already sent the User ID (got using simple Hubl inject) to amplitude by writing to  localstorage. If not in localstorage, it sends it. If it is, then it ignores.

 

The Amplitude integration doesn't really do what I need across the board as it happens.

 

Thanks for getting back to me in any case. Been a steep but pretty enjoyable learning curve!

 

Freddy

TomM2
Thought Leader | Platinum Partner
Thought Leader | Platinum Partner

Getting value from browser when executing workflow

SOLVE

Oh fair play! That does sound like a bit of a learning curve alright! Happy I could help somewhat! 

Tom Mahon
Technical Consultant | Solutions Engineer | Community Champion
Baskey Digitial

Book a consultation

Did my post help answer your query? Help the community (and me) by marking it as a solution.


0 Upvotes