Google Analytics Custom Event Track for Lead Flows

forms

#1

Looking to see if there’s any way to track lead flows as a custom event in Google Analytics?

Some of the Lead Flows are on external pages. We do not have the events tool within HubSpot.

If there is not a direct solution, is there a workaround?


#2

I would also like to learn about this - scripts inserted in the lead flow thankyou message are rendered as rich text. Tracking this seems fairly bread and butter…


#3

Has anyone found a solution to custom event tracking for lead flows?


#4

For lead flows:

window.addEventListener('message', event => {
    // Check if the event was sent by Hubspot
    if(event.data.accepted && event.data.conversionId) {

        // Trigger the event to Google Analytics
        ga('send', 'event', 'Form', 'send', 'Hubspot form');
    }
});