首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Javascript干扰GTM

Javascript干扰GTM
EN

Stack Overflow用户
提问于 2018-09-13 23:06:58
回答 1查看 47关注 0票数 0

我发现手风琴脚本干扰了GTM设置来跟踪PDF下载。手风琴脚本打开并折叠下载链接列表。它实际上是两个脚本;第一个启动ddaccordion.js,第二个设置参数。

它们在头上,然后我在页末试了一下--没什么区别。如果我删除一个或另一个脚本,GTM将开始跟踪下载。所有其他PDF下载轨道通常整个网站。

以下是两个脚本:

代码语言:javascript
复制
    <script type="text/javascript" src="js/ddaccordion.js">

    /*••••••••••••••••••••••••••••••••••••••••••••••
    • Accordion Content script- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
    • Visit http://www.dynamicDrive.com for hundreds of DHTML scripts
    • This notice must stay intact for legal use
    ••••••••••••••••••••••••••••••••••••••••••••••*/

    </script>

    <script type="text/javascript">


        ddaccordion.init({
                headerclass: "expandable", //Shared CSS class name of headers group that are expandable
                contentclass: "categoryitems", //Shared CSS class name of contents group
                revealtype: "click", //Reveal content when user clicks or onmouseover the header? Valid value: "click", "clickgo", or "mouseover"
                mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
                collapseprev: true, //Collapse previous content (so only one open at any time)? true/false 
                defaultexpanded: [], //index of content(s) open by default [index1, index2, etc]. [] denotes no content
                onemustopen: false, //Specify whether at least one header should be open always (so never all headers closed)
                animatedefault: true, //Should contents open by default be animated into view?
                persiststate: false, //persist state of opened contents within browser session?
                toggleclass: ["", "openheader"], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
                togglehtml: ["prefix", "", ""], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
                animatespeed: "2500", //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
                oninit:function(headers, expandedindices){ //custom code to run when headers have initalized
                    //do nothing
                },
                onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed
                document.getElementById('main-content').style.height=document.getElementById('side-bar').style.height=document.getElementById('photo-bar').style.height=document.getElementById('anchor').offsetTop+'px';;

                //do nothing   "side-bar", "main-content", "photo-bar"
                }
            })


    </script>

有没有办法在不失去手风琴功能的情况下解决这个问题?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-09-14 18:57:31

解决方案是将ddaccordion.js脚本(只发生一次)中的“返回false”替换为"e.preventDefault()“。感谢@的解决方案。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52322890

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档