I want to Track Hubspot forms with Click Text “Download Now”, but i am not able to track it.
Here is the process i have followed
Created a Tag
>>Tag Configuration >>Custom HTML
and placed this HTML code
<script type=“text/javascript”>
window.addEventListener(“message”, function(event) {
if(event.data.type === ‘hsFormCallback’ && event.data.eventName === ‘onFormSubmit’) {
window.dataLayer.push({
‘event’: ‘hubspot-form-data’,
‘hs-form-guid’: event.data.id,
‘hs-formData’: event.data.data
});
}
});
window.addEventListener(“message”, function(event) {
if(event.data.type === ‘hsFormCallback’ && event.data.eventName === ‘onFormSubmitted’) {
window.dataLayer.push({
‘event’: ‘hubspot-form-success’,
‘hs-form-guid’: event.data.id
});
}
});
</script>
Then added a trigger to this tag Trigger >> Trigger Configuration >> Custom Event
Event name: hubspot-form-success >> Some Custom Events
and added this condition
Click Text Contains Download Now
then created a TAG for GA-4 Event
added measurement id >>
Event Name: Download_Now_Whitepaper >>
Event Parameter: Click_text
Value: {{Click Text}}
then fired this on “All Pages”
My Tags are firing but my all the forms on the website are created through hubspot forms and whenever, some one fills any form above tag got fired and tracked as Event but i only want to track forms having Click button “Download Now”
Please help me what i can do in it.
