CMS - 如何轻松设置?
一两天内我一直在想一件事。我想知道,如果我在提交按钮上添加一些 jQuery 的评论,那么创建一个文件会很愚蠢吗 - 例如:
tracking.php?Param=[...]
然后可以制作的所有内容分析中的目标将有它自己的参数。该文件不必包含任何代码 - 文件的访问应该足以进行分析,对吧?
因此,如果我在我的系统中有两个公式并希望为每个公式设置一些目标并使用tracking.php作为我的“目标URL”,这是一个好的方法:
在jQuery中调用该文件,如下所示: track.php?Param=form1 track.php?Param=form2
如上所述,该文件不会有任何内容 - 只是一个空文件。因此它不应该有任何延迟 - 是这样吗?
或者这只是我在深思熟虑后想出的一个糟糕的解决方法?
I have been wondering a thing in a day or two. I was wondering that if I am e.g. Adding a comment with some jQuery on a submit button would it then be stupid to make a file - for example:
tracking.php?Param=[...]
And then Everything that can be made to a goal in analytics will have it's own parameter. The file does not have to include any code - the visit of the file should be enough for analytics, right?
So if I in my system has two formulars and want to have set up some goals on each of them and use tracking.php as my "goal-URL" is this an okay way to do so:
Calling the file in jQuery as this:
tracking.php?Param=form1
tracking.php?Param=form2
As mentioned above the file would not have any content - just an empty file. And therefore it shouldn't make any delay - is that right?
OR is this just a bad workaound, that I have come up with in some late hours of thinking?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,这是行不通的。 GA代码需要在某个时间点执行。 GA 不会自动跟踪 javascript (jquery) 发出的请求。
在这一点上,正如 Mads Jenson 提到的,你正在重新发明轮子。不幸的是,由于一些奇怪的原因,你不能使用自定义变量或事件作为目标,只能使用 URL...我听说 GA 最终将添加它,但在那之前,你只能通过弹出虚拟页面视图来实现目标。
因此,在给定页面上,如果您想跟踪某些内容作为目标,只需调用以下内容:
您可以在 virtualPage 中放置您想要的任何值,但“/tracking/”作为前缀,后跟特定值是一种干净的方式这样做,类似于您拥有一个带有唯一参数值的 url 的想法(尽管如果您愿意,您可以完全按照您输入的方式传递它...)。
您可以将其放入包装函数中,以便在单击、悬停、经过一定时间后、如果满足其他条件时调用...无论您想要什么。
但请注意,GA 允许的请求数量有限制实现每次访问,所以不要疯狂地将跟踪阳光下的所有内容作为目标,否则您可能最终会因为跟踪您所做的其他自定义跟踪,甚至是基本页面视图而搞砸自己命中...
First off, that's not going to work. GA code needs to be executed at some point in time. GA does not automatically track requests made by javascript (jquery).
And on that note, as Mads Jenson mentioned, you are reinventing the wheel. Unfortunately for some weird reason, you cannot use custom variables or events as goals, only URLs...I hear rumors that GA is going to eventually add that in, but until then, you are stuck with popping virtual page views to make goals.
So, on a given page, if you want to track something as a goal, just call the following:
you would put whatever value you want in virtualPage but "/tracking/" as a prefix, followed by a specific value is a clean way to do it, and is similar to your idea of having a single url w/ unique parameter values (though you can pass it exactly as you put it if you want...).
You can put that in a wrapper function to be called on an onclick, hover, after a certain amount of time has passed, if some other condition is met... whatever you want.
But fair warning, there is a limit to how many requests GA will allow to make to it in per visit, so don't go crazy with tracking everything under the sun as a goal, or you may end up screwing yourself on tracking other custom tracking you've done, or even basic page view hits...