简体   繁体   中英

How to implement Omniture custom link tracking for on click event?

I'm looking to implement Omniture custom link tracking code on 3 links of one page. I've been provided some javascript code but not sure if I need this in the page or if I just need to incorporate it into the onclick portion of the link.

I have not done this before and have tried to read up on it here ( http://microsite.omniture.com/t2/help/en_US/sc/implement/oms_sc_implement.pdf ) and here ( https://developer.omniture.com/en_US/content_page/sitecatalyst-tagging/c-add-a-custom-link ) but it does not make much sense to me.

Here's is what I have done so far:

  1. Included link to s_code.js after opening body tag

2 . Grab code that was provided by Omniture to track one of the links

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

3 . Reviewed an example of Omniture custom link tracking

<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>

I think from comparing, that my links should be coded like this:

<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>

Does that seem correct? Do I need to include the scripts from #2. somewhere else on the page for it to track the links?

The code provided to me did not have any s.prop items as seen in the example, do I need them?

Is there anyway to know via the console if the links are tracked on click?

Thanks,

** * ** * **** UPDATE * ** * ** * ** * ** * ** * ** * ** * ** * ****

Sorry seems I was unclear before since everyone is explaining the example I was provided and not the code I am trying to implement.

This is the code I have produced and am wondering if it is correct. I am using jQuery on the page.

<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>

I think it is suggested I should remove this code from each link s.linkTrackVars= s.linkTrackVars+',eVar45,events';

To track the clicks, you may call the .tl() function, the following is code from my production environment:

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

This of course, assumes that s is the Ommniture global variable. I am also using specific data (got this directly from my code), so you don't really need to set all of that up, just the pageName, or whichever variable you are capturing. I am also using jQuery for the selector, do not let that confuse you, you can just call a normal JavaScript function, and call s.tl() .

To debug (track the clicks), use their debugger by adding the following script as a Bookmark for your browser:

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>"));

Just click the Bookmark whenever you want to track Omniture events.

DigitalPulse Debugger : http://helpx.adobe.com/analytics/using/digitalpulse-debugger.html

your code is fine as-is, though it's cleaner to wrap it in a separate function and call the function in your onclick or attach the function call via a click event handler (eg what Hanlet showed).

One thing to note is that you may not really want to append those vars to the existing s.linkTrackVars value. This may produce unintended consequences as far as stuff getting rolled up into the request. For example, let's say you have some other click/link/custom tracking on the page (some other thing that pops an s.tl call) with different variables being set. If you append to s.linkTrackVars like that and someone already popped the other code, it's going to roll up those other vars again since they would have values.

Example, let's say you have these 2 links on a page. First one is for custom download tracking. 2nd one is your link you posted:

<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>

If you click the download link first, linkTrackVars will have eVar1 appended to it, and you will be giving eVar1 a value. Then let's say you click the 2nd link. Because you are appending more values to linkTrackVars instead of only setting relevant vars, eVar1 value is going to be popped along with your 2nd link click.

Now, in this case, that's not a big deal because this only really affects the instance metric in your reporting, and nobody really cares about that. But if you expand this scenario to any other vars you happen to have set that should only be popped at specific times, well this could make for some inflation.

So the takeaway here is that normally you shouldn't append to linkTrackVars unless you know what you're doing or have evaluated the situation and have determined it's not going to inadvertently inflate other vars.

Since you are using the tl() call, that is a partial data call. Meaning, not a full page load/call. So, basically you are sending a subset of data. In my usage, I usually don't append the linkTrackVars unless you want to track them too, again.

So, this seems appropriate.

<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
})

You can grab the debugger than Hanlet suggests, or just use firefox debugger. look on "net" and search for "metrics", or get httpwatch - and see your call going out.

note: I am assuming you are using jQuery, so I use that convention for event handling of the link. If you don't have jQuery, you can just use native js code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM