Loop elements with Jquery and call Omniture s.tl() function to track
Posted
by ilovewebdev
on Stack Overflow
See other posts from Stack Overflow
or by ilovewebdev
Published on 2010-05-11T12:02:51Z
Indexed on
2010/05/12
3:44 UTC
Read the original article
Hit count: 214
Hi, 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');
}
The problem is only the last item (in the list) has its value sent to Omniture when i clicked on a.printAll
. I finally got the above to work in IE but not Firefox. Anyone encounter this before?
© Stack Overflow or respective owner