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:
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.
However, throughout the site I've used a combination of absolute and relative links, so I have links that look like this:
...and so on. How can I make it so that jQuery sets the page tracker in the format "/visit/website-a/" every time? Any ideas?