Google Analytics(分析)_trackEvent不适用于XHTML? [英] Google Analytics _trackEvent doesn't work with XHTML?
问题描述
我有一个生成XHTML内容的php文件,我使用
I have a php file generating XHTML content and I use
<?php header('Content-type: application/xhtml+xml');?>
可以在页面顶部执行此操作。但是,我的谷歌分析事件跟踪完全拒绝工作,当标签存在。如果我删除该标签,事件跟踪将再次开始。我根本没有改变跟踪代码,只是删除了一个定义为XHTML的php标签。
at the top of the page to do so. However, my google analytics event tracking absolutely refuses to work when that tag is present. If I remove that tag, event tracking begins to fire again. I am not altering the tracking code at all, just removing that one php tag defining the page as XHTML.
<a href="some-file.zip" onClick="_gaq.push(['_trackEvent', 'Item', 'Download', 'file-name']);">Download File</a>
我需要这样定义页面,Safari和Firefox 3.6才能正确呈现SVG图像I在那里,所以删除它是不是一种选择,除非有其他方式让Safari和Firefox 3.6渲染SVG图像。
I need the page to be defined that way so Safari and Firefox 3.6 will correctly render the SVG images I have on there, so removing it isn't an option unless there's some other way to make Safari and Firefox 3.6 render SVG images.
编辑:我正在通过跟踪进行调试所有与Firebug。
I'm debugging by tracking everything with Firebug.
推荐答案
你有没有尝试从内联锚元素中删除JavaScript并创建一个包装在CDATA中的侦听器标签?
Have you tried removing the javascript from the inline anchor element and creating a listener which is wrapped in a CDATA tag?
示例:
Example:
<a id="my_anchor" href="someZip.zip">Click me</a>
<script type="text/javascript">
/* <![CDATA[ */
// Ensure scope for _gaq ....
// Jquery syntax..
$('#my_anchor').click(function()
{
_gaq.push(['_trackEvent', 'Item', 'Download', 'file-name']);
});
/* ]]> */
</script>
这篇关于Google Analytics(分析)_trackEvent不适用于XHTML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!