5

我一直在创建一些网站,这些网站使用 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() 调用,以作为额外页面视图跟踪的任何内容。例如,您为“图书”链接设置了以下点击事件处理程序

$('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数组来做到这一点?

4

2 回答 2

6

许多个月前,我不得不为 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>
于 2011-11-20T07:02:18.077 回答
0

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

你可以试试。

于 2011-12-22T09:36:33.890 回答