google analytics code via literal eingesetzt

Hilfe zu Modulen und Tags
Post Reply
dylan

google analytics code via literal eingesetzt

Post by dylan »

Eine Frage zur Korrektheit

Ich habe einer Seite den google-analytics code unterm schließenden body-Tag hinzugefügt

Code: Select all

<__script__ type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</__script>
<__script__ type="text/javascript">
try {
var pageTracker = _gat._getTracker("xx-xx-xx");
pageTracker._trackPageview();
} catch(err) {}</__script>
und erhielt dadurch die folgende Fehlermeldung:

string(114) "Smarty error: [in tpl_body:20 line 70]: syntax error: unrecognized tag 'var' (Smarty_Compiler.class.php, line 590)" string(110) "Smarty error: [in tpl_body:20 line 71]: syntax error: unrecognized tag: (Smarty_Compiler.class.php, line 446)" string(111) "Smarty error: [in tpl_body:20 line 71]: syntax error: unrecognized tag '' (Smarty_Compiler.class.php, line 590)"

Im smarty.net/manual habe ich den {literal} Tag ausfindig gemacht und den code entspr. eingesetzt:

Code: Select all

{literal}
<__script__ type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</__script>
<__script__ type="text/javascript">
try {
var pageTracker = _gat._getTracker("xx-xx-xx");
pageTracker._trackPageview();
} catch(err) {}</__script>
{/literal}
Die Fehlermeldung verschwand, der Code wird im Quelltext korrekt angezeigt.

Meine Frage:
Ist die Nutzung von literal dafür geeignet?
Wie setzt Ihr google analytics code ein?
nicmare
Power Poster
Power Poster
Posts: 1150
Joined: Sat Aug 25, 2007 9:55 am
Location: Berlin

Re: google analytics code via literal eingesetzt

Post by nicmare »

es geht nur damit. also alles richtig gemacht. bravo
Post Reply

Return to “Module und Tags”