Omniture跟踪和jQuery

时间:2011-11-17 14:58:45

标签: javascript jquery html adobe-analytics

我一直在创建一些网站,内容被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>

无论如何要解决这个问题,并使用将跟踪代码应用于特定#div#的if语句创建几行Javascript吗?

更新:

我与一位专家交谈,并表示您可以在onClick事件中添加额外的s.t()调用,以便将您想要跟踪的任何内容添加为其他页面视图。例如,您为“图书”链接设置了以下点击事件处理程序

$('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数组执行此操作?

2 个答案:

答案 0 :(得分:5)

很多时候,我不得不为Web CMS系统设置Omniture的分析工具,特别是我们公司的产品和购物车组件。代码包含在我们网站模板的每个页面上(即包含文件)。假设您的站点不是完全静态的站点,您可以执行相同的操作,将代码放在.js文件,模板,包含文件,母版页,视图中(无论您在站点范围内重用的方法是什么)。如果我没记错的话,Omniture坚持在关闭身体标签之前完全拥有它的代码。代码到位后,写一些javascript以将值分配给特定变量,以用于在Omniture代码中设置适当的值。例如,如果您的页面偶然创建了一个很好的SEO标题,您可以从标题中提取值以用于Omniture页面名称。这只是一个例子。

另一方面,如果您的网站是静态网站,那么您的选择并不容易。如果你能掌控你的div是如何产生的,你会更好。我的意思是,如果你能以传统方式将数据返回给div,你可以使用javascript或你最喜欢的javascript库(例如jQuery)为你的Omniture变量生成适当的信息。更进一步,如果您完全控制HTML的生成方式,您可以添加一个特定的类来注意,就像您的a.manned-flight示例一样。但是,我会为所有类型的点击寻找更通用的东西。

就像我说的,如果你能控制渲染的数据,那么从呈现的HTML中提取数据会更容易。否则,提供Omniture所需的有意义信息将更加困难。希望这会有所帮助。

这是我对你的问题理解有限的想法。假设您的数据采用标准格式,如下图所示。

<div class="product-item">
    <input class='item-title' type='hidden' value='Book Title #1 Specific Page Name'/>
    <input class='other-stuff-for-analytics' type='hidden' value='More stuff here'/>
    <h3>Book Title #1</h3>
    <p>Description of Book Title #1 and some junk...</p>
</div>
<div class="product-item">
    <input class='item-title' type='hidden' value='Book Title #2 Specific Page Name'/>
    <input class='other-stuff-for-analytics' type='hidden' value='More stuff here'/>
    <h3>Book Title #2</h3>
    <p>Description of Book Title #2 and some junk...</p>
</div>
<div class="product-item">
    <input class='item-title' type='hidden' value='Book Title #3 Specific Page Name'/>
    <input class='other-stuff-for-analytics' type='hidden' value='More stuff here'/>
    <h3>Book Title #3</h3>
    <p>Description of Book Title #3 and some junk...</p>
</div>

<!-- The code below could be in your template/include file/master page/view/ .js file -->
<script>
    $('div.product-item').click(function () {
        var analyticsPageName = "";
        /* Possibly pull the value from hidden input  */
        analyticsPageName = $(this).children('input.item-title').val();

        /* OR Pull the information from the block of HTML that has the page title */
        analyticsPageName = $(this).children('h3').text();

        // ---OR---
        //whatever else you need to do to scrape your HTML
        //to get the information to plug into a variable

        s.pageName = analyticsPageName;
        s.t();
        $('html, body').animate({
            scrollTop: 1250
        }, 1000, function () {
            parallaxScroll(); // Callback is required for iOS
        });
        return false;
    });
</script>

答案 1 :(得分:0)

我认为Jquery有一个名为jquery.address的插件库,它实现了一种基于JQuery的动作的自动跟踪。 此库本身配置为 Google Analytics ,但过去我还添加了Omniture SiteCatalyst代码。

你可以试试。