Separate your analytics code into a separate template.
It's probably because you have the analytics code INSIDE another EE loop and so it's trying to parse it as a template variable.
So isolate the code if you need it within the loop and create an embedded template to include.
Thus, create an include called .analytics.
In the .analytics template, do the following (I'm using Google Analytics as an example):
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxx-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>
NOTE: Using this method, keep the template as a normal template, do NOT change it to a javascript template because you are using the <script type="text/javascript">
tags inside the template.
Then, in your main template, do a simple:
{embed="template_group/.analytics"}
And you will be good to go.