Everytime I add the tacking code to the source code on the websiet, EE strip it out. Is there anyway to get it to stay without using a plugin?
2 Answers
Just to echo Johnathan's answer, I put my Google Analytics tracking code in a Global Variable (usually called footer) which is added to each template.
Put it in the template as opposed to in a field type. If you need to be able to change the number, just make that a field instead. Just put this in the template and replace {yourfieldhere}
<script>
var _gaq=[['_setAccount','{yourfieldhere}'],['_trackPageview']];
setTimeout("_gaq.push(['_trackEvent', '15_seconds', 'read'])",15000);
(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';
s.parentNode.insertBefore(g,s)}(document,'script'));
</script>