When starting with Google Analytics, the tracking statistics might seem complex and overwhelming at first. However, after a certain time it becomes clear that important information is missing. Lately, I ran into the problem that the analytics are by default not tracking any external links, making it hard to define their usefulness on websites. Certain that Google had an solution to this problem, I searched and found information about external link tracking, explaining the event tracking methods provided by the Google Analytics API. Though the provided information does indeed do a great job at tracking external links and other events, implementing it on a large website would be an extremely hard task since every external links must be equipped with an ‘onclick’-event. Using some basic JavasScript knowledge, I came up with the following script that automatically adds this event to all absolute links (starting with the protocol ‘http://’) on the page. Please note that your website should use relative links for internal links to prevent them from being tracked with this script and that (for Internet Explorer compatibility) you should edit the cURI value at the top.
- Login per inviare commenti
- 277 letture



