|
|
Line 1: |
Line 1: |
| // Code to insert Google Analytics:
| |
|
| |
|
| var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
| |
|
| |
| document.write("\x3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'\x3E\x3C/script\x3E");
| |
|
| |
| addOnloadHook(trackPageView)
| |
|
| |
| function trackPageView() {
| |
| try {
| |
| var pageTracker = _gat._getTracker("UA-8316288-7");
| |
| pageTracker._trackPageview();
| |
| } catch(err) {}
| |
| }
| |
|
| |
| // Code to track external links via google analytics
| |
|
| |
| // Cross-browser implementation of element.addEventListener()
| |
| function addListener(element, type, expression, bubbling) {
| |
| bubbling = bubbling || false;
| |
|
| |
| if (window.addEventListener) { // Standard
| |
| element.addEventListener(type, expression, bubbling);
| |
| return true;
| |
| } else if (window.attachEvent) { // IE
| |
| element.attachEvent('on' + type, expression);
| |
| return true;
| |
| } else return false;
| |
| }
| |
| //This is what i want to do whenever someone clicks on the page
| |
| function itHappened(evt) {
| |
|
| |
| //Get the clicket element
| |
| var tg = (window.event) ? evt.srcElement : evt.target;
| |
| //If it is an A element
| |
| if (tg.nodeName == 'A') {
| |
| //And it is not an internal link
| |
| if (tg.href.indexOf(location.host) == -1) {
| |
| //Replace all odd characters, so that it works with Analytics Navigation analysis
| |
| var url = tg.href.replace(/[^a-z|A-Z|0-9]/g, "_");
| |
| //var txt = tg.innerHTML.replace(/[^a-z|A-Z|0-9]/g, "_");
| |
| //var str = '/outgoinglink/-' + txt + '-' + url;
| |
| var str = '/outgoinglink/-' + url;
| |
| try {
| |
| //Track it
| |
| var pageTracker = _gat._getTracker("UA-8316288-7");
| |
| pageTracker._trackPageview(str);
| |
| }
| |
| catch (err) {
| |
| //alert('error: ' + err);
| |
| }
| |
| }
| |
| }
| |
| }
| |
| //Add the click listener to the document
| |
| addListener(document, 'click', itHappened);
| |