如何在点击事件上实现Omniture自定义链接跟踪?

时间:2014-01-21 23:20:06

标签: javascript adobe-analytics

我希望在一个页面的3个链接上实现Omniture自定义链接跟踪代码。我已经提供了一些javascript代码,但不确定我是否需要在页面中使用它,或者我只是需要将它合并到链接的onclick部分。

我之前没有这样做,并尝试在此处阅读(http://microsite.omniture.com/t2/help/en_US/sc/implement/oms_sc_implement.pdf)和此处 (https://developer.omniture.com/en_US/content_page/sitecatalyst-tagging/c-add-a-custom-link) 但这对我来说没有多大意义。

这是我到目前为止所做的:

  1. 打开正文标记后包含指向s_code.js的链接
  2. 2。抓取Omniture提供的代码来跟踪其中一个链接

    s.linkTrackVars="eVar45,events";s.linkTrackEvents="event23";s.eVar45="MaturingEquityLines|RenewEquityLOCOverlay"; s.events="event23";s.tl(this,'o','MaturingEquityLines|RenewEquityLOCOverlay');
    

    3。查看了Omniture自定义链接跟踪的示例

    <a href="#" id="community_overlay_trigger" class="delicious" onClick="s.linkTrackVars= s.linkTrackVars+',events,eVar8,prop8,prop13'; s.events='event6'; s.linkTrackEvents='event6'; s.eVar8=s.prop8='delicious'; s.prop13=s.pageName; s.tl(this,'o','Content Share');">delicious</a>
    

    我认为通过比较,我的链接应该像这样编码:

    <a href="#" id="popoverBtn1" class="popoverThis btn btn-default" data-  placement='bottom' onClick="s.linkTrackVars= s.linkTrackVars+',eVar45,events'; s.events='event23'; s.linkTrackEvents='event23'; s.eVar45='MaturingEquityLines|RenewEquityLOCOverlay'; s.tl(this,'o','MaturingEquityLines|RenewEquityLOCOverlay');">Learn More <span class="glyphicon glyphicon-circle-arrow-right"></span></a>
    

    这看起来是否正确?我是否需要包含#2中的脚本。页面上的其他地方是否可以跟踪链接?

    提供给我的代码没有任何s.prop项,如示例中所示,我是否需要它们?

    无论如何,通过控制台知道是否点击了链接?

    谢谢,

    ** * ** * **** 更新 * ** * ** * ** * ** < EM> * ** * ** * ** * ** * *** *

    对不起似乎我之前不清楚,因为每个人都在解释我提供的示例而不是我想要实现的代码。

    这是我制作的代码,我想知道它是否正确。我在页面上使用jQuery。

    <div class="col-md-4">
          <img src="house.gif" alt="House Symbol" />
          <h4>Renew Your<br />Equity Line of Credit</h4>
          <a href="#" id="popoverBtn1" class="popoverThis btn btn-default" data-placement='bottom' onClick="s.linkTrackVars= s.linkTrackVars+',eVar45,events'; s.events='event23'; s.linkTrackEvents='event23'; s.eVar45='MaturingEquityLines|RenewEquityLOCOverlay'; s.tl(this,'o','MaturingEquityLines|RenewEquityLOCOverlay');">Learn More <span class="glyphicon glyphicon-circle-arrow-right"></span></a>
          <div id="popoverContent1" class="hide"><strong>Ideal for:</strong> Qualified clients who want to continue having the convenient access to funds that a home equity line of credit provides.<br /><br /><strong>What:</strong> Apply for a new Access 3<sup>&reg;</sup> Equity Line and transfer your current balance to the new line. <a target="_blank" href="https://www.suntrust.com/PersonalBanking/Loans/EquityLinesOfCreditAndLoans/EquityLineOfCredit">Learn More</a> about our Access 3<sup>&reg;</sup> Equity Line.<br /><br /><strong>Get started:</strong> <a target="_blank" href="https://www.suntrust.com/portal/server.pt?space=Redirect&amp;CommunityID=1805&amp;ui_ProdGroup=IL&amp;ui_ProdSubGroup=EQLN&amp;ui_Product=INETACCX&amp;POPNAC=T">Apply Online</a>, Call <span class="blue">877-748-4059</span>, or stop by your <a target="_blank" href="https://www.suntrust.com/FindUs">local branch</a>.
          </div>
        </div>
        <div class="col-md-4">
          <img src="money.gif" alt="Money Symbol" />
          <h4>Pay Off the<br />Current Balance</h4>
          <a href="#" id="popoverBtn2" class="popoverThis btn btn-default" data-placement='bottom' onClick="s.linkTrackVars= s.linkTrackVars+',eVar45,events'; s.events='event23'; s.linkTrackEvents='event23'; s.eVar45='MaturingEquityLines|PayOffCurrentBalanceOverlay'; s.tl(this,'o','MaturingEquityLines|PayOffCurrentBalanceOverlay');">Learn More <span class="glyphicon glyphicon-circle-arrow-right">Learn More <span class="glyphicon glyphicon-circle-arrow-right"></span></a>
          <div id="popoverContent2" class="hide"><strong>Ideal for:</strong> Clients who no longer need an equity line of credit and are in a financial position to begin repaying their balance with the new monthly payments.<br /><br /><strong>What:</strong> Begin to pay off the balance of your existing equity line of credit when the draw period ends.<br /><br /><strong>Get started:</strong> Continue to make regular payments under the repayment period terms of your existing home equity line of credit; no further action is required.
          </div>
        </div>
        <div class="col-md-4">
          <img src="note.gif" alt="Note Symbol" />
          <h4>Sign a Repayment<br />Extension</h4>
          <a href="#" id="popoverBtn3" class="popoverThis btn btn-default" data-placement='bottom' onClick="s.linkTrackVars= s.linkTrackVars+',eVar45,events'; s.events='event23'; s.linkTrackEvents='event23'; s.eVar45='MaturingEquityLines|SignRepaymentExtensionOverlay'; s.tl(this,'o','MaturingEquityLines|SignRepaymentExtensionOverlay');">Learn More <span class="glyphicon glyphicon-circle-arrow-right">Learn More <span class="glyphicon glyphicon-circle-arrow-right">Learn More <span class="glyphicon glyphicon-circle-arrow-right"></span></a>
          <div id="popoverContent3" class="hide" style="z-index:-1;"><strong>Ideal for:</strong> Clients who anticipate having a difficult time making higher monthly payments when their draw period ends.<br /><br /><strong>What:</strong> Modify your existing repayment term and extend the repayment period which allows you to make lower monthly fixed-rate payments.<br /><br /><strong>Get started:</strong> Call us at <span class="blue">888-886-0696</span>, Monday &ndash; Friday 8 am to 6 pm ET, and request a Repayment Extension.* We will mail you the extension with instructions on completing and returning it.<br /><br /><span class="dis"><em>* By submitting this request, Federal Regulations require SunTrust Bank to determine if your home is located in a Special Flood Hazard Area as designated by the FEMA Flood Maps for your community. If your home is determined to be in a flood zone A or V, you will be required to obtain and maintain acceptable flood insurance coverage for the remaining term of your equity line or loan. This requirement is not dependent upon the approval of your modification. Once a flood zone determination is made, withdrawal of the modification request will not eliminate the flood insurance requirement for zones A and V. Unfortunately a lender placed flood policy is not acceptable by law to allow us to proceed with the modification even if the agreement is executed. If at any point during the term of your line or loan we are notified that you are located in a Special Flood Hazard Area, the bank is required by Federal Law to ensure that adequate flood insurance is on file for your property.</em></span>
          </div>
    

    我认为建议我从每个链接s.linkTrackVars= s.linkTrackVars+',eVar45,events';

    中删除此代码

3 个答案:

答案 0 :(得分:4)

要跟踪点击次数,您可以调用.tl()函数,以下是我的生产环境中的代码:

$(".myDiv a").on("click", function () 
{
    var pageName = $(this).text().trim();
    if (s && pageName != "") {
        s.pageName = originalPageName + ":FAQ:" + pageName
        s.tl();
    }
});

当然,这假设s是Ommniture全局变量。我也在使用特定的数据(直接从我的代码中获取),所以你真的不需要设置所有这些,只需要设置pageName,或者你捕获的任何变量。我也在为选择器使用jQuery,不要让你感到困惑,你可以调用普通的JavaScript函数,然后调用s.tl()

要调试(跟踪点击次数),请使用他们的调试器,将以下脚本添加为浏览器的书签:

javascript:void(window.open("","dp_debugger","width=600,height=600,location=0,menubar=0,status=1,toolbar=0,resizable=1,scrollbars=1").document.write("<script language=\"JavaScript\" id=dbg src=\"https://www.adobetag.com/d1/digitalpulsedebugger/live/DPD.js\"></"+"script>"));

只要您想跟踪Omniture活动,只需点击书签即可。

DigitalPulse调试器http://helpx.adobe.com/analytics/using/digitalpulse-debugger.html

答案 1 :(得分:0)

你的代码很好,尽管将它包装在一个单独的函数中并在你的onclick中调用函数或通过click事件处理程序附加函数调用(例如Hanlet显示的内容)更清晰。

有一点需要注意的是,您可能并不想将这些变量附加到现有的s.linkTrackVars值。就填充到请求中的内容而言,这可能会产生意想不到的后果。例如,假设您在页面上有一些其他点击/链接/自定义跟踪(其他一些弹出s.tl调用的东西),并设置了不同的变量。如果您追加s.linkTrackVars之类的,并且有人已经弹出了其他代码,那么它将会再次卷起其他变量,因为它们会有值。

示例,假设您在页面上有这两个链接。第一个是自定义下载跟踪。第二个是您发布的链接:

<a href='someFile.pdf' onclick="s.eVar1='some widget';s.linkTrackVars+=',eVar1';s.tl(this,'o','file downloaded');return false;">some file</a>

<a href="#" id="community_overlay_trigger" class="delicious" onClick="s.linkTrackVars= s.linkTrackVars+',events,eVar8,prop8,prop13'; s.events='event6'; s.linkTrackEvents='event6'; s.eVar8=s.prop8='delicious'; s.prop13=s.pageName; s.tl(this,'o','Content Share');">delicious</a>

如果您先点击下载链接,linkTrackVars会附加eVar1,您将获得eVar1一个值。然后让我们说你点击第二个链接。由于您要向linkTrackVars附加更多值而不是仅设置相关变量,因此eVar1值将随您的第二次链接点击一起弹出。

现在,在这个的情况下,并不是什么大不了的事情,因为这只会影响您报告中的实例指标,没有人真正关心它。但是,如果你将这个场景扩展到任何其他vars,你碰巧设置了只应该在特定时间弹出,那么这可能会导致一些通货膨胀。

所以这里的内容是,通常你不应该附加linkTrackVars,除非你知道你正在做什么或已经评估过这种情况,并且已经确定它不会无意中膨胀其他变量。

答案 2 :(得分:0)

由于您正在使用tl()调用,这是部分数据调用。意思是,不是整页加载/调用。所以,基本上你是在发送一个数据子集。在我的使用中,我通常不会附加linkTrackVars,除非你想再次跟踪它们。

所以,这似乎是合适的。

<a href="#" id="community_overlay_trigger" class="delicious">delicious</a>


jQuery('#community_overlay_trigger').bind('click', function(event){
       s.linkTrackVars = 'events,eVar8,prop8,prop13';
       s.linkTrackEvents='event6'
       s.events='event6';
       s.eVar8=s.prop8='delicious';
       s.prop13=s.pageName || "no pagename given";
       s.tl(this, 'o', 'Content Share');
       event.preventDefault(); // or return false here
})

你可以获得比H​​anlet建议的调试器,或者只使用firefox调试器。查看“网络”并搜索“指标”,或获取httpwatch - 并查看您的通话结束。

注意:我假设您正在使用jQuery,因此我使用该约定来处理链接的事件。如果你没有jQuery,你可以使用原生的js代码。