# Add Tracking Events on different forms for GTA

**URL:** <https://community.hubspot.com/t/add-tracking-events-on-different-forms-for-gta/35892>\
**Category:** CMS Development\
**Tags:** starter\
**Created:** [April 21, 2021, 2:17pm UTC](https://community.hubspot.com/t/add-tracking-events-on-different-forms-for-gta/35892 "2021-04-21T14:17:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![AYadav](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/ayadav/32/47092_2.png) [@AYadav](https://community.hubspot.com/u/AYadav)\
**Post date:** [April 21, 2021, 2:17pm UTC](https://community.hubspot.com/t/add-tracking-events-on-different-forms-for-gta/35892/1 "2021-04-21T14:17:31Z")

</div>

I need help how to add different Tracking events to different hubspot forms, these are forms used on pages using forms module and are not embedded forms

For embedded I can use this code  
{% require\_js %}  
\<script\>  
hbspt.forms.create({  
portalId: ‘your\_portal\_id’,  
formId: ‘{{ module.form\_field.form\_id }}’,  
onFormSubmit: function($form) {  
window.dataLayer = window.dataLayer || [];  
window.dataLayer.push [{  
‘eventName’: ‘trackingEvent’,  
‘eventCategory’: ‘forms’,  
‘eventAction’: ‘submit’,  
‘eventLabel’: ‘pricing’  
}];  
}  
});  
\</script\>  
{% end\_require\_js %}

But for the module forms where do I add different events, as the code goes like this  
{% form  
form\_to\_use=“{{ module.form\_field\_1.form\_id }}”  
response\_response\_type=“{{ module.form\_field\_1.response\_type }}”  
response\_message=“{{ module.form\_field\_1.message }}”  
response\_redirect\_id=“{{ module.form\_field\_1.redirect\_id }}”  
response\_redirect\_url=“{{module.form\_field\_1.redirect\_url}}”  
gotowebinar\_webinar\_key=“{{ module.form\_field\_1.gotowebinar\_webinar\_key }}”  
%}

Any help on this would be highly appreciated, it a urgent task

Thankyou

---

<div class="post-metadata">

**Author:** ![dennisedson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dennisedson/32/28044_2.png) [@dennisedson](https://community.hubspot.com/u/dennisedson)\
**Post date:** [April 21, 2021, 5:53pm UTC](https://community.hubspot.com/t/add-tracking-events-on-different-forms-for-gta/35892/2 "2021-04-21T17:53:13Z")

</div>

@dbeau79 , @Gonzalo , would either of you be able to assist @AYadav ?

---

<div class="post-metadata">

**Author:** ![dbeau79](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dbeau79/32/82797_2.png) [@dbeau79](https://community.hubspot.com/u/dbeau79)\
**Post date:** [April 21, 2021, 6:49pm UTC](https://community.hubspot.com/t/add-tracking-events-on-different-forms-for-gta/35892/3 "2021-04-21T18:49:56Z")

</div>

@AYadav , I’ve only done this using the embed code but I believe you could do this using a global form event like this:

```lia-code-sample
window.addEventListener('message', event => {
 if(event.data.type === 'hsFormCallback' && event.data.eventName === 'onFormSubmit') {
window.dataLayer = window.dataLayer || [];
window.dataLayer.push [{
'eventName': 'trackingEvent',
'eventCategory': 'forms',
'eventAction': 'submit',
'eventLabel': 'pricing'
 }
});

```

Documentation: [Accounts Dashboard | HubSpot](https://legacydocs.hubspot.com/global-form-events)
