Buying Simple jQuery Script

Discussion in 'Programming' started by Inersha, Apr 2, 2011.

  1. #1
    I want to add tracking to my outbound links for Google Analytics using jQuery. The outbound links are sent through a redirect in a directory called "visit".

    So far, I've got this script:

    
    $(document).ready(function(){
    						   
    $("a[href*='/visit/']").click(function(){
    	
    	pageTracker._trackPageview('$(this).attr('href')');
     
    	});
    
    });
    
    Code (markup):
    This seems almost perfect (do I not need to escape any inverted commas?), as it sets the virtual pageview as the link in the href. For example, if the link is pointing to a redirect in the folder /visit/website-a/, the pageview gets set as /visit/website-a/ too. This is exactly what I want.

    However, throughout the site I've used a combination of absolute and relative links, so I have links that look like this:

    ../visit/website-a/
    ../../../visit/website-a/
    /visit/website-a/
    visit/website-a/

    ...and so on. So what I'm looking for, is someone that is able to manipulate the href contents so that it is in the same "/visit/website-a/" format every time. So if the link in the html is like "../../../visit/website-a/" or "visit/website-a/" or "../visit/website-a/" etc., the pageview tracker gets set as "/visit/website-a/" once clicked using jQuery.

    I'd also like to talk over a few small customisable options so that I can use the same script on different sites that have slightly varying names for folders containing the outbound redirected links.

    Send me a PM if you think you can create a script that can do this. Also include a quote for the job.

    Thanks!
     
    Inersha, Apr 2, 2011 IP