我发现手风琴脚本干扰了GTM设置来跟踪PDF下载。手风琴脚本打开并折叠下载链接列表。它实际上是两个脚本;第一个启动ddaccordion.js,第二个设置参数。
它们在头上,然后我在页末试了一下--没什么区别。如果我删除一个或另一个脚本,GTM将开始跟踪下载。所有其他PDF下载轨道通常整个网站。
以下是两个脚本:
<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>有没有办法在不失去手风琴功能的情况下解决这个问题?
发布于 2018-09-14 18:57:31
解决方案是将ddaccordion.js脚本(只发生一次)中的“返回false”替换为"e.preventDefault()“。感谢@的解决方案。
https://stackoverflow.com/questions/52322890
复制相似问题