Gaudicia wrote: > Hello, > > I just started looking into JQuery and I have a few questions. Mostly > about how to make tagging my links with google analytics tracking > faster. > > I want to be able to track my outgoing links, which I've read is > possible, but I really haven't see anything about tracking third party > booking engines. > > So basically what I want is this. > > If I have links linking to my domain or an eCommerce or booking > engine, I don't want those links to be tagged as outgoing. However, > if the link is to a booking engine/eCommerce I want them to be tagged > like this: > > <a href=" https://www.securecart.com/?store=parameters" > onclick="pageTracker._link(this.href); return false;">Purchase Now</a> > or like this <a > href="javascript:openWindow(pageTracker._getLinkerUrl('http:// > bookingengine.com'))">Booking Engine</a>
Well, I'd avoid the href="javascript:...." technique as it wont fail very gracefully with a non-javascript enabled browser and as this is a booking engine, I'd imagine this could affect your bottom line. I'd generate all your links with a certain class and then do something like: $(document).ready(function(){ $('a.tracker').click(function(){ /// do the tracking; return true }); }); On all pages. That will apply the tracking function to all href's click element and allow the click to bubble down to be handled by the browser in a new way (sans javascript). If you want a new window, just use target="_blank" as normal. > I also want to add this onsubmit="pageTracker._linkByPost(this)" to > the forms that are submitting to the booking engine. Again, just put a class on your form and use a similar event registration function to above in order to do this automatically. HTHs Col