简体   繁体   English

Google跟踪代码管理器导致页面表单提交两次

[英]Google Tag Manager causing page form to submit twice

I have a webpage - which i guess is fairly standard. 我有一个网页-我认为这是相当标准的。

Basically something like: 基本上像这样:

<form action="/mywebsite/mypage" method="post" novalidate="novalidate">
  <div class="blah">                    
    <input class="form-control" id="name" maxlength="80" name="name" tabindex="1" type="text" value="">
    <!-- tonnes more inputs and labels and stuff -->
    <input type="submit" class="btn" value="Submit" tabindex="2">   
  </div>
</form>

But when the submit button is pressed, the form is submitted twice (depending on browser). 但是,当按下提交按钮时,表单将提交两次(取决于浏览器)。

Firefox - works fine - submits once consistantly Firefox-工作正常-一致提交一次
Chrome - intermittent, mostly works, sometimes submits twice. Chrome-断断续续的,大多数情况下都有效,有时会提交两次。
IE (Edge) - submits twice 100% of the time IE(Edge)-100%的时间提交两次

Managed to narrow it down to google tag manager. 设法缩小到谷歌标签管理器。 When this is removed it works fine. 删除后,它可以正常工作。

So I have this script in my _layout page (master page, template page, whatever you call it) 所以我在_layout页面(母版页,模板页,无论您叫什么)中都有此脚本

<!-- Google Tag Manager -->
<noscript>
    <iframe src="//www.googletagmanager.com/ns.html?id=GTM-ABCDEF1"
            height="0" width="0" style="display: none; visibility: hidden">
    </iframe>
</noscript>
<script>
    (function(w, d, s, l, i) {
        w[l] = w[l] || [];
        w[l].push({
            'gtm.start':
                new Date().getTime(),
            event: 'gtm.js'
        });
        var f = d.getElementsByTagName(s)[0],
            j = d.createElement(s),
            dl = l != 'dataLayer' ? '&l=' + l : '';
        j.async = true;
        j.src =
            '//www.googletagmanager.com/gtm.js?id=' + i + dl;
        f.parentNode.insertBefore(j, f);
    })(window, document, 'script', 'dataLayer', 'GTM-ABCDEF1');
</script>

<!-- End Google Tag Manager -->

So I'm trying to understand what's going on - why it would be causing it - and how to stop it. 所以我试图了解正在发生的事情-为什么会导致它-以及如何阻止它。
I can work around it - but I don't want to. 我可以解决它-但我不想。 Would rather fix it properly. 宁愿正确修复它。

Notes: yes for some reason the url starts // rather than https:// - but changing it makes no difference. 注意:是,由于某种原因,URL以//而不是https://开头-但是更改它没有区别。

Any ideas? 有任何想法吗?

I have a very basic understanding of google analytics - but 0 knowledge about google tag manager. 我对Google Analytics(分析)有一个非常基本的了解-但对Google Tag Manager的了解为0。

A bug in GTM, see https://productforums.google.com/forum/?nomobile=true#!topic/tag-manager/QVb2sNyvp5k;context-place=forum/tag-manager for more information. GTM中的错误,请参阅https://productforums.google.com/forum/?nomobile=true#!topic/tag-manager/QVb2sNyvp5k;context-place=forum/tag-manager了解更多信息。 The selected answer isn't really the correct answer. 所选答案并非真正正确的答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM