Has anyone managed to use the GA event tracker sucessfully? I am having poblems and am seeking suggestions. I have the GA code on the header of the pages and am using the event tracker code below <a href="http://www.mydomain/mydoc.pdf" target="_blank" onClick="javascript: pageTracker._trackPageview('http://www.mydomain/mydoc.pdf.pdf');"> Can anyone see a problem with this code? ... below is the main page header code I am using ... <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-1780XXX0-1']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script> Thanks gordano
When you attach an onclick event, you don't include the protocol (javascript:...) in there. replace this onClick="javascript: pageTracker._trackPageview('http://www.mydomain/mydoc.pdf.pdf');" Code (markup): with this onclick="return pageTracker._trackPageview('http://www.mydomain/mydoc.pdf.pdf') ? true : true;" Code (markup): I include the "return" to make sure that javascript executes before the visitor navigates away from the page.
Joebert Thanks for the suggestion. I tried this but still showing zero events tracked. It is puzzling me, if anyone on this forum can check the code and fix this for me I'll pay $10