Blog, Website & Page Publishing

FF2
Participant

Prevent Cookie tracking of a specific form

SOLVE

Hello,

 

I am using Hubspot on my site http://www.7Plusclub.de, which is running on wordpress.

I found out, that using the hubspot option “Collect data from website forms”, which can be found in the “Non Hubspot Forms” menu works perfectly fine for me to track any <form> submissions on my website.

 

However, I have one form, in which my users do not type their own email address, but an email address of another member in order to contact him. As soon as this form is submitted, the data transferred to hubspot is a complete mess, because the cookie is interpreted with a wrong email address.

 

Is there any hack / tag / exclude I can use, to prevent tracking of this single specific form on my website? E.G. a class name like <form class=”doNotTrack”>?

0 Upvotes
1 Accepted solution
AdityaBansal
Solution
Member | Platinum Partner
Member | Platinum Partner

Prevent Cookie tracking of a specific form

SOLVE

Hi @FF2

I've found 2 possible solutions to your problem. Since you are looking to prevent tracking from single specific form, you can try either of the following ways.

  1. I noticed that when you specify in HubSpot to collect info from non-HubSpot forms, it attempts to add the script collectedforms.js to your website. However, before doing so, it checks to see if it's already installed by using the document.getElementById method where the ID is CollectedForms-1234 (1234 is the ID at the end of your tracking script). Therefore, if you simply put any HTML element on your page with that ID, such as <span id="CollectedForms-1234"></span>, it won't install the collectedforms.js file, meaning it also won't collect information on your non-HubSpot forms. While still a hack, it doesn't force you to change your forms, and it's much easier to conditionally add it based on where the user is in your app. Just be sure that this element exists statically on your website, and isn't loaded dynamically.

  2. What you need to do is add the following code to it:

    <label for="amex" style="display:none">AMEX</label>
    <input type="hidden" name="amex" required="" value="" id="amex">

    HS JS tracking code will deem your form as one that contains sensitive data and will ignore it. 

View solution in original post

6 Replies 6
FGaletic5
Participant

Prevent Cookie tracking of a specific form

SOLVE

Hi, for the non developers, could you specify where this code is added? Thanks!

0 Upvotes
FRaI
Member

Prevent Cookie tracking of a specific form

SOLVE

Its now matching the TagName too, meaning the ID has to be in a <script> tag.

Inside https://js-na1.hs-scripts.com/1234.js:

 

var i=document.getElementsByTagName("script")[0];i.parentNode.insertBefore(n,i)}}("CollectedForms-1234",XY......

 

You have to specify it as follows, to not have it tracked by HubSpot:

 

<script id="CollectedForms-1234"></script>
<!-- stops Hubspot collection -->

 

Can you verify that too?

0 Upvotes
FF2
Participant

Prevent Cookie tracking of a specific form

SOLVE

Do I now need both tags or just the new script tags including the id attribute?

0 Upvotes
FF2
Participant

Prevent Cookie tracking of a specific form

SOLVE

1. Works like a charm - THANK YOU!!!!

0 Upvotes
AdityaBansal
Member | Platinum Partner
Member | Platinum Partner

Prevent Cookie tracking of a specific form

SOLVE

I'm glad I could help @FF2

 

Could you please mark my answer as solution to help others as well?

0 Upvotes
AdityaBansal
Solution
Member | Platinum Partner
Member | Platinum Partner

Prevent Cookie tracking of a specific form

SOLVE

Hi @FF2

I've found 2 possible solutions to your problem. Since you are looking to prevent tracking from single specific form, you can try either of the following ways.

  1. I noticed that when you specify in HubSpot to collect info from non-HubSpot forms, it attempts to add the script collectedforms.js to your website. However, before doing so, it checks to see if it's already installed by using the document.getElementById method where the ID is CollectedForms-1234 (1234 is the ID at the end of your tracking script). Therefore, if you simply put any HTML element on your page with that ID, such as <span id="CollectedForms-1234"></span>, it won't install the collectedforms.js file, meaning it also won't collect information on your non-HubSpot forms. While still a hack, it doesn't force you to change your forms, and it's much easier to conditionally add it based on where the user is in your app. Just be sure that this element exists statically on your website, and isn't loaded dynamically.

  2. What you need to do is add the following code to it:

    <label for="amex" style="display:none">AMEX</label>
    <input type="hidden" name="amex" required="" value="" id="amex">

    HS JS tracking code will deem your form as one that contains sensitive data and will ignore it.