<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Setting up GTM tracking for form submissions where the checkbox has been checked in APIs &amp; Integrations</title>
    <link>https://community.hubspot.com/t5/APIs-Integrations/Setting-up-GTM-tracking-for-form-submissions-where-the-checkbox/m-p/293659#M27453</link>
    <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've set up form tracking on GTM, but I'm now having issues with tracking specifically form submissions where the opt-in checkbox has also been checked. I've discovered that the ID&amp;nbsp;&lt;/P&gt;&lt;P&gt;attribute of the checkbox is dynamic, which is why my custom javascript variable no longer works. This is what I have currently (which worked before the last four digits of the ID changed):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;function() {&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp; var checkbox = document.getElementById("LEGAL_CONSENT.subscription_type_6337149-8b3f66b8-292e-411d-a20e-f08f28554e60_7739");&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp; return checkbox.checked || false;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;}&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there an easy workaround for this, such as selecting the element by an ID that starts with the portion that doesn't change?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;EDIT:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've replaced it with the following, but it's still not firing:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;function() {&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;var checkbox = document.querySelector('[id^="LEGAL_CONSENT.subscription_type_6337149-8b3f66b8-292e-411d-a20e-f08f28554e60_"]');&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;return checkbox.checked || false;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;}&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 27 Sep 2019 14:28:05 GMT</pubDate>
    <dc:creator>Joanne_Lam</dc:creator>
    <dc:date>2019-09-27T14:28:05Z</dc:date>
    <item>
      <title>Setting up GTM tracking for form submissions where the checkbox has been checked</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Setting-up-GTM-tracking-for-form-submissions-where-the-checkbox/m-p/293659#M27453</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've set up form tracking on GTM, but I'm now having issues with tracking specifically form submissions where the opt-in checkbox has also been checked. I've discovered that the ID&amp;nbsp;&lt;/P&gt;&lt;P&gt;attribute of the checkbox is dynamic, which is why my custom javascript variable no longer works. This is what I have currently (which worked before the last four digits of the ID changed):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;function() {&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp; var checkbox = document.getElementById("LEGAL_CONSENT.subscription_type_6337149-8b3f66b8-292e-411d-a20e-f08f28554e60_7739");&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp; return checkbox.checked || false;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;}&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there an easy workaround for this, such as selecting the element by an ID that starts with the portion that doesn't change?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;EDIT:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've replaced it with the following, but it's still not firing:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;function() {&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;var checkbox = document.querySelector('[id^="LEGAL_CONSENT.subscription_type_6337149-8b3f66b8-292e-411d-a20e-f08f28554e60_"]');&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;return checkbox.checked || false;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;}&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Sep 2019 14:28:05 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Setting-up-GTM-tracking-for-form-submissions-where-the-checkbox/m-p/293659#M27453</guid>
      <dc:creator>Joanne_Lam</dc:creator>
      <dc:date>2019-09-27T14:28:05Z</dc:date>
    </item>
    <item>
      <title>Re: Setting up GTM tracking for form submissions where the checkbox has been checked</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Setting-up-GTM-tracking-for-form-submissions-where-the-checkbox/m-p/293876#M27471</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/106393"&gt;@Joanne_Lam&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope all is well with you &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When testing this out in my own portal by creating a form with a legal consent check box:&amp;nbsp;&lt;A href="https://share.hsforms.com/1txjHms06RQilN62vK0KEmw2tvo8" target="_blank"&gt;https://share.hsforms.com/1txjHms06RQilN62vK0KEmw2tvo8,&lt;/A&gt; I'm not seeing the subscription link ID being dynamic.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this case, do you mind sharing with me the Hub ID, the form ID/name and the page that the form is on? So that I can look into things further here!&lt;/P&gt;</description>
      <pubDate>Mon, 30 Sep 2019 02:04:47 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Setting-up-GTM-tracking-for-form-submissions-where-the-checkbox/m-p/293876#M27471</guid>
      <dc:creator>WendyGoh</dc:creator>
      <dc:date>2019-09-30T02:04:47Z</dc:date>
    </item>
    <item>
      <title>Re: Setting up GTM tracking for form submissions where the checkbox has been checked</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Setting-up-GTM-tracking-for-form-submissions-where-the-checkbox/m-p/293988#M27491</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/66274"&gt;@WendyGoh&lt;/a&gt;,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All's well thank you, and likewise to you&amp;nbsp;&lt;img id="smileyvery-happy" class="emoticon emoticon-smileyvery-happy" src="https://community.hubspot.com/i/smilies/16x16_smiley-very-happy.png" alt="Smiley Very Happy" title="Smiley Very Happy" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for taking the time to respond and look into this as it's had me stumped for a good few days!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hub ID: 5565170&lt;/P&gt;&lt;P&gt;Form ID: 8b3f66b8-292e-411d-a20e-f08f28554e60 (although when I view the variables summary on Tag Manager when doing a test submission, there are 4 extra digits at the end after an underscore.)&lt;/P&gt;&lt;P&gt;Page:&amp;nbsp;&lt;A href="https://resources.symec.co.uk/future-proofing-your-business" target="_blank"&gt;https://resources.symec.co.uk/future-proofing-your-business&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Sep 2019 15:36:23 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Setting-up-GTM-tracking-for-form-submissions-where-the-checkbox/m-p/293988#M27491</guid>
      <dc:creator>Joanne_Lam</dc:creator>
      <dc:date>2019-09-30T15:36:23Z</dc:date>
    </item>
    <item>
      <title>Re: Setting up GTM tracking for form submissions where the checkbox has been checked</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Setting-up-GTM-tracking-for-form-submissions-where-the-checkbox/m-p/294075#M27506</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/106393"&gt;@Joanne_Lam&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for sharing these information across!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Digging further into this, I can confirm that there has been a recent changes made such that the form is more unique with an additional id that you observe after the underscore.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If you were previously targeting the ID to style the form, you can use the class name instead (e.g. #&lt;/SPAN&gt;&lt;SPAN&gt;hsForm_8b3f66b8-292e-411d-a20e-f08f28554e60 to .&lt;/SPAN&gt;&lt;SPAN&gt;hsForm_8b3f66b8-292e-411d-a20e-f08f28554e60). *&lt;EM&gt;Changing the # to a .&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Keep a look up here:&amp;nbsp;&lt;A href="https://developers.hubspot.com/changelog" target="_blank"&gt;https://developers.hubspot.com/changelog&lt;/A&gt;&amp;nbsp;for the detailed change annoucement.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Oct 2019 02:12:14 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Setting-up-GTM-tracking-for-form-submissions-where-the-checkbox/m-p/294075#M27506</guid>
      <dc:creator>WendyGoh</dc:creator>
      <dc:date>2019-10-01T02:12:14Z</dc:date>
    </item>
    <item>
      <title>Re: Setting up GTM tracking for form submissions where the checkbox has been checked</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Setting-up-GTM-tracking-for-form-submissions-where-the-checkbox/m-p/294389#M27569</link>
      <description>&lt;P&gt;Thanks for the suggestion&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/66274"&gt;@WendyGoh&lt;/a&gt;!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, it's actually the dynamic ID of the subscription checkbox that's causing the issue as I can track the form submissions just fine.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The initial bit of script I used to track the checkbox worked until the next day when I found that the ID had changed. Is there any workaround for this particular issue?&lt;/P&gt;</description>
      <pubDate>Wed, 02 Oct 2019 12:52:54 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Setting-up-GTM-tracking-for-form-submissions-where-the-checkbox/m-p/294389#M27569</guid>
      <dc:creator>Joanne_Lam</dc:creator>
      <dc:date>2019-10-02T12:52:54Z</dc:date>
    </item>
    <item>
      <title>Re: Setting up GTM tracking for form submissions where the checkbox has been checked</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Setting-up-GTM-tracking-for-form-submissions-where-the-checkbox/m-p/294574#M27592</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/106393"&gt;@Joanne_Lam&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The reason I mentioned about the dynamic form id change made recently is because due to the form id change, the check box ID was affected as well. Though the ID may change, the submission will still come through just fine.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may want to grab the following class element instead:&lt;/P&gt;
&lt;PRE&gt;.hsForm_8b3f66b8-292e-411d-a20e-f08f28554e60 .legal-consent-container .hs-form-booleancheckbox-display input&lt;/PRE&gt;</description>
      <pubDate>Thu, 03 Oct 2019 01:51:29 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Setting-up-GTM-tracking-for-form-submissions-where-the-checkbox/m-p/294574#M27592</guid>
      <dc:creator>WendyGoh</dc:creator>
      <dc:date>2019-10-03T01:51:29Z</dc:date>
    </item>
  </channel>
</rss>

