Omniture 跟踪和 jQuery
我一直在创建一些网站,其中的内容通过 jQuery 和 CSS 调用 #div 容器来提取。有谁知道在创建这些类型的单页网站时使用 Omniture Site Catalyst 跟踪代码的方法吗?可能的?
以前,我一直通过插入软件提供的以下难以辨认的代码块来将 Omniture 与更传统的 html 网站结合使用。在这种情况下,它似乎跟踪所有 .html 页面。
<!-- SiteCatalyst Code version: H.17.
Copyright 1997-2008 Omniture, Inc. More info available at
http://www.omniture.com -->
<script language="JavaScript" type="text/javascript" src="http://www.urlofsite.com/js/s_code.js"></script>
<script language="JavaScript" type="text/javascript"><!--
/************* DO NOT ALTER ANYTHING BELOW THIS LINE ! **************/
var s_code=s.t();if(s_code)document.write(s_code)//--></script>
<script language="JavaScript" type="text/javascript"><!--
if(navigator.appVersion.indexOf('MSIE')>=0)document.write(unescape('%3C')+'\!-'+'-')
//--></script><noscript><a href="http://www.omniture.com" title="Web Analytics"><img
src="http://code.urlofsite.com/b/ss/ranhrollup/1/H.17--NS/0"
height="1" width="1" border="0" alt="" /></a></noscript><!--/DO NOT REMOVE/-->
<!-- End SiteCatalyst code version: H.17. -->
</body>
</html>
是否有办法打破这种情况,并使用 if 语句创建几行 Javascript,将跟踪代码应用于特定的 #div#
?
更新:
我与一位专家交谈过,他表示您可以在 onClick 事件中为您希望作为附加页面视图进行跟踪的任何内容添加附加的 st() 调用。例如,您为“Books”链接设置了以下单击事件处理程序,
$('a.manned-flight').click(function() {
$('html, body').animate({
scrollTop: 1250
}, 1000, function() {
parallaxScroll(); // Callback is required for iOS
});
return false;
});
您可以向此函数添加跟踪代码以指定不同的 pageName 并发送额外的页面视图图像请求,如下所示:
$('a.manned-flight').click(function() {
s.pageName = "www.urlofwebsite.com:Books";
s.t();
$('html, body').animate({
scrollTop: 1250
}, 1000, function() {
parallaxScroll(); // Callback is required for iOS
});
return false;
});
但如何使用网站有多大,以及我必须定义多少内容区域,这似乎是一种不切实际的方法,而且在代码方面有些笨拙。有没有办法用 Javascript 数组来做到这一点?
I've been creating a few websites with content being pulled with jQuery and CSS calling to the #div containers. Does anyone know a way to use Omniture Site Catalyst tracking code while creating these types of one page websites? Possible?
Previously I've been utilizing Omniture with more traditional html sites by inserting the below chunk of hardly legible code provided by the software. It which case it seems to track all the the .html pages.
<!-- SiteCatalyst Code version: H.17.
Copyright 1997-2008 Omniture, Inc. More info available at
http://www.omniture.com -->
<script language="JavaScript" type="text/javascript" src="http://www.urlofsite.com/js/s_code.js"></script>
<script language="JavaScript" type="text/javascript"><!--
/************* DO NOT ALTER ANYTHING BELOW THIS LINE ! **************/
var s_code=s.t();if(s_code)document.write(s_code)//--></script>
<script language="JavaScript" type="text/javascript"><!--
if(navigator.appVersion.indexOf('MSIE')>=0)document.write(unescape('%3C')+'\!-'+'-')
//--></script><noscript><a href="http://www.omniture.com" title="Web Analytics"><img
src="http://code.urlofsite.com/b/ss/ranhrollup/1/H.17--NS/0"
height="1" width="1" border="0" alt="" /></a></noscript><!--/DO NOT REMOVE/-->
<!-- End SiteCatalyst code version: H.17. -->
</body>
</html>
Is there anyway to break that up, and create a few lines of Javascript with if statements that apply the tracking code to specific #div#
?
Update:
I spoke with a specialist and he stated that you can add additional s.t() calls in the onClick events for anything you wish to track as an additional page view. As an example, you have the following click event handler set up for the "Books" link
$('a.manned-flight').click(function() {
$('html, body').animate({
scrollTop: 1250
}, 1000, function() {
parallaxScroll(); // Callback is required for iOS
});
return false;
});
You can add tracking code to this function to specify a different pageName and send off an additional Page View image request as follows:
$('a.manned-flight').click(function() {
s.pageName = "www.urlofwebsite.com:Books";
s.t();
$('html, body').animate({
scrollTop: 1250
}, 1000, function() {
parallaxScroll(); // Callback is required for iOS
});
return false;
});
But with how large the site is and how much content areas I'd have to define, this seems like an impractical approach and somewhat clunky, code wise. Is there anyway to do this with a Javascript array?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
许多个月前,我必须为 Web CMS 系统设置 Omniture 的分析工具,特别是我们公司的产品和购物车组件。该代码包含在我们网站模板的每个页面上(即包含文件)。假设您的站点不是完全静态的站点,您可以执行相同的操作,将代码放入 .js 文件、模板、包含文件、母版页、视图中(无论您可能使用站点范围内重用的任何方法)。如果我没记错的话,Omniture 坚持将其代码恰好放在结束正文标记之前。代码就位后,编写一些 JavaScript 来为特定变量分配值,以便在 Omniture 代码中设置适当的值。例如,如果您的页面偶然创建了一个不错的 SEO 标题,您可以从标题中提取值以用于 Omniture 页面名称。这只是一个例子。
另一方面,如果您的网站是静态网站,您的选择就不那么容易了。如果您能够控制 div 的生成方式,您的情况会更好。我的意思是,如果您可以以传统方式将数据返回到 div,则可以使用 javascript 或您最喜欢的 javascript 库(例如 jQuery)为 Omniture 变量生成适当的信息。更进一步,如果您可以完全控制 HTML 的生成方式,则可以添加要注意的特定类,就像 a.manned-flight 示例中的情况一样。但是,我会寻找适合所有类型点击的更通用的东西。
就像我说的,如果您可以控制渲染的数据,那么从渲染的 HTML 中提取数据就会更容易。否则,将很难提供 Omniture 所需的有意义的信息。希望这有帮助。
这是我对你的问题的有限理解所想到的。假设您的数据采用标准格式,如下例所示。
Many moons ago, I had to set up Omniture's analytics tool for a Web CMS system, specifically our companies product and shopping cart components. The code was included on every page in our site template (ie. include file). Assuming your site is not completely static site, you could do the same, putting the code in your .js file, template, include file, master page, view (whatever method you might be using site-wide reuse). If I recall correctly, Omniture was adamant on having it's code EXACTLY before the closing body tag. Once the code is in place, write up some javascript to assign values to particular variables to be used to set the appropriate values in the Omniture code. For example, if, by chance, your page is creating a nice SEO title, you could pull the value from the title to be used for the Omniture page name. That's just an example.
On the other hand, if your site is a static site, your options are not as easy. You would be better off if you had control of how your div's were being generated. What I mean by that is if you could return the data to you div's in a conventional manner, you could generate the appropriate information for your Omniture variables by using javascript or your favorite javascript library (eg. jQuery). Even further, if you had complete control of how the HTML was generated, you could add a specific class to watch out for, as is the case with your example of a.manned-flight. However, I would be looking for something more generic for all types of clicks.
Like I said, if you have control of the data that gets rendered, things will be easier to pull the data from the rendered HTML. Otherwise, it will be harder to provide the meaningful info needed by Omniture. Hope this helps.
This is kind of what I'm thinking with my limited understanding of your problem. Assuming your data is in a standard format like sample below.
我认为 Jquery 有一个名为
jquery.address
的插件库,它实现了一种对基于 JQuery 的操作的自动跟踪。该库本机配置为 Google Analytics,但过去我还添加了 Omniture SiteCatalyst 代码。
你可以尝试一下。
I think that Jquery has a plugin library called
jquery.address
which implement a sort of automatic tracking of JQuery based action.This library if natively configured for Google Analytics, but in the past I added also Omniture SiteCatalyst code.
You can try that.