<?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 Re: How to send a HubSpot form field using data layer to google tag manager? in Lead Capture Tools</title>
    <link>https://community.hubspot.com/t5/Lead-Capture-Tools/How-to-send-a-HubSpot-form-field-using-data-layer-to-google-tag/m-p/703160#M8069</link>
    <description>&lt;P&gt;I have also tried this approach before. I can get the sent variable in Google Tag Manager inside Messages section but not inside the variable that I have highlighted.&lt;/P&gt;</description>
    <pubDate>Fri, 07 Oct 2022 06:33:50 GMT</pubDate>
    <dc:creator>naser_sadeghi</dc:creator>
    <dc:date>2022-10-07T06:33:50Z</dc:date>
    <item>
      <title>How to send a HubSpot form field using data layer to google tag manager?</title>
      <link>https://community.hubspot.com/t5/Lead-Capture-Tools/How-to-send-a-HubSpot-form-field-using-data-layer-to-google-tag/m-p/702595#M8059</link>
      <description>&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;SPAN&gt;I have a HubSpot form in my website where I am trying to get leads from the users. As the webpage is also connected to an active Google Ads account, I need to send the input field which holds the email to Google Tag Manager. To do so first of all, I wrote the following code in my website's&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&amp;lt;head&amp;gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;section:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;PRE&gt;&amp;lt;head&amp;gt;
    ...
    &amp;lt;script&amp;gt;
        &lt;SPAN class=""&gt;window&lt;/SPAN&gt;.&lt;SPAN class=""&gt;dataLayer&lt;/SPAN&gt; = &lt;SPAN class=""&gt;window&lt;/SPAN&gt;.&lt;SPAN class=""&gt;dataLayer&lt;/SPAN&gt; || [];
    &amp;lt;/script&amp;gt;
    ...
&amp;lt;/head&amp;gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;SPAN&gt;Then, I created a Data Layer variable in Google Tag Manager dashboard which looks like below:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="tag_manager.png" style="width: 933px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/76600i83869FE7DFF62B7B/image-size/large?v=v2&amp;amp;px=999" role="button" title="tag_manager.png" alt="tag_manager.png" /&gt;&lt;/span&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;P&gt;Finally, in my HubSpot form, I added&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;onFormSubmitted&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;function which looks like below to push the variable and its value (the user's email) to Tag Manager:&lt;/P&gt;&lt;PRE&gt;&amp;lt;script charset=&lt;SPAN class=""&gt;"utf-8"&lt;/SPAN&gt; type=&lt;SPAN class=""&gt;"text/javascript"&lt;/SPAN&gt;
    src=&lt;SPAN class=""&gt;"//js-eu1.hsforms.net/forms/shell.js"&lt;/SPAN&gt;&amp;gt;&amp;lt;/script&amp;gt;
&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&amp;lt;&lt;SPAN class=""&gt;script&lt;/SPAN&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;    hbspt.&lt;SPAN class=""&gt;forms&lt;/SPAN&gt;.&lt;SPAN class=""&gt;create&lt;/SPAN&gt;({
        &lt;SPAN class=""&gt;region&lt;/SPAN&gt;: &lt;SPAN class=""&gt;"eu1"&lt;/SPAN&gt;,
        &lt;SPAN class=""&gt;portalId&lt;/SPAN&gt;: &lt;SPAN class=""&gt;"xxxxxxxx"&lt;/SPAN&gt;,
        &lt;SPAN class=""&gt;formId&lt;/SPAN&gt;: &lt;SPAN class=""&gt;"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"&lt;/SPAN&gt;,
        &lt;SPAN class=""&gt;onFormSubmitted&lt;/SPAN&gt;: &lt;SPAN class=""&gt;function&lt;/SPAN&gt; (&lt;SPAN class=""&gt;$form&lt;/SPAN&gt;) {
            dataLayer.&lt;SPAN class=""&gt;push&lt;/SPAN&gt;({ &lt;SPAN class=""&gt;'var'&lt;/SPAN&gt;: &lt;SPAN class=""&gt;String&lt;/SPAN&gt;($form.&lt;SPAN class=""&gt;find&lt;/SPAN&gt;(&lt;SPAN class=""&gt;'input[name="email"]'&lt;/SPAN&gt;).&lt;SPAN class=""&gt;val&lt;/SPAN&gt;()) });
        }
    });&lt;/SPAN&gt;&lt;SPAN class=""&gt;&amp;lt;/&lt;SPAN class=""&gt;script&lt;/SPAN&gt;&amp;gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;SPAN&gt;After adding these pieces of codes, when I check the&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Google Ads Submit Lead Form Conversion&lt;/STRONG&gt;&lt;SPAN&gt;, I still can't see the value.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;SPAN&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="tag_manager_2.png" style="width: 518px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/76601i719ADE24F5F16661/image-size/large?v=v2&amp;amp;px=999" role="button" title="tag_manager_2.png" alt="tag_manager_2.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 06 Oct 2022 07:15:14 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/Lead-Capture-Tools/How-to-send-a-HubSpot-form-field-using-data-layer-to-google-tag/m-p/702595#M8059</guid>
      <dc:creator>naser_sadeghi</dc:creator>
      <dc:date>2022-10-06T07:15:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to send a HubSpot form field using data layer to google tag manager?</title>
      <link>https://community.hubspot.com/t5/Lead-Capture-Tools/How-to-send-a-HubSpot-form-field-using-data-layer-to-google-tag/m-p/702800#M8065</link>
      <description>&lt;P&gt;From what I can see you are trying to get the data in the onFormSubmitted event. Unfortunately, while it would be useful to have the data here, the data is no longer accessible at that point. &amp;nbsp;So you would need to grab the data via onFormSubmit which is after the data is validated, but before it is sent to Hubspot. &amp;nbsp;Can you try changing the hubspot embed and see if that resolves the issue?&lt;/P&gt;</description>
      <pubDate>Thu, 06 Oct 2022 13:37:46 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/Lead-Capture-Tools/How-to-send-a-HubSpot-form-field-using-data-layer-to-google-tag/m-p/702800#M8065</guid>
      <dc:creator>Ben_M</dc:creator>
      <dc:date>2022-10-06T13:37:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to send a HubSpot form field using data layer to google tag manager?</title>
      <link>https://community.hubspot.com/t5/Lead-Capture-Tools/How-to-send-a-HubSpot-form-field-using-data-layer-to-google-tag/m-p/703160#M8069</link>
      <description>&lt;P&gt;I have also tried this approach before. I can get the sent variable in Google Tag Manager inside Messages section but not inside the variable that I have highlighted.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Oct 2022 06:33:50 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/Lead-Capture-Tools/How-to-send-a-HubSpot-form-field-using-data-layer-to-google-tag/m-p/703160#M8069</guid>
      <dc:creator>naser_sadeghi</dc:creator>
      <dc:date>2022-10-07T06:33:50Z</dc:date>
    </item>
  </channel>
</rss>

