0

i have a page with a list of items. Each item has a print now link (a.printMe) to print each item. At the end of the list, there's a print all link (a.printAll) to print all items.

I want to track number of times an item was printed. If a.printAll link is clicked, then i will send all the item's tracking value to Omniture. I added tracking string into individual item's a.printMe href attribute and track with the following functions:

$('a.printMe').click(function() {
   var value = $(this).attr('href');
   track(value);
});

$('a.printAll').click(function() {
   $('a.printMe').each(function() {
      this.click();
   }); // works in IE only. IE 6-8
}); 

function track(value) {
   var s = s_gi('account');
   s.prop10 = value;
   s.linkTrackVars = 'prop10';
   s.tl(true, 'o');
}

In IE 6-8, all the values are posting fine when i clicked on a.printAll. I understand that in Firefox, click event is only for input elements. So i implemented the below:

$('a.printMe').each(function() {
   var trackingCode = $(this).attr('href').replace('#','');
   track(trackingCode);
});

But only the last item's value is sent to Omniture. Has anyone implemented something like this and work?

zen.c
  • 678
  • 8
  • 17
  • 1
    "in Firefox, click event is only for input elements". This is inaccurate. The click event in Firefox fires for clicks all types of elements. – GlenCrawford May 12 '10 at 04:58
  • Sorry i should have made myself clear.. What i am trying to implement is to simulate a mouse click. From mozilla website: The click method is intended to be used with INPUT elements of type button, checkbox, radio, reset or submit. Gecko does not implement the click method on other elements that might be expected to respond to mouse–clicks such as links (A elements), nor will it necessarily fire the click event of other elements. – zen.c May 13 '10 at 02:11

2 Answers2

1

If there is no third argument, the function tries to read the href, but since this fails it doesn't work as intended.

As a side note, I would like to point out that simply adding a custom link value of "all" instead of sending one hit for each link would be preferred. With that many server calls you just cause extra traffic (which could be used better) and might end up with unreliable data (some requests might fail).

Sampsa Suoninen
  • 624
  • 4
  • 9
0

FIXED: s.tl(true, 'o'); should include value as the last param.

So end result should be s.tl(true, 'o', value);

zen.c
  • 678
  • 8
  • 17
  • hmm... 3rd argument of s.tl() is an optional argument, to give the "link" a friendly name for reporting purposes. I doubt that adding that in there really fixed your problem..what else did you do? – CrayonViolent Jul 25 '10 at 00:39
  • Hi Crayon, that's all i did. Basically the values are printing in the firebug console. But its just that the network activity shows that only the last value is being sent. Adding the value as the last param works for me ;) – zen.c Aug 22 '10 at 15:30