I am trying to add the Google Analytics tracking code to a hubspot page. However the tracking should ONLY happen, if and when the user has submitted a form.
I have been searching around for a while, and as I see it, this is a more difficult task, than it needs to be? have you found a nice solution to this?
My thoughts (after I found out that I couldn't add code to the submit button), was to create a "thank-you" landingpage and redirecting to it after submit, and then send tracking from there - But my client really wants the "inline thank you" message -
Can I please hear your thoughts and ideas, since I'm new to hubspot
HubSpot does a have a callback method for submit. You could trigger your analytics from the Analytics JS API - https://developers.google.com/analytics/devguides/collection/analyticsjs/events
hbspt.forms.create({
css: '',
onFormSubmit: function(){
ga('send', 'event', 'Videos', 'play', 'Fall Campaign');
}
});