Add javascript in php code and php code in Javascript
<p>I am trying to get the info from a PHP variable in to JavaScript while in the PHP <code>if</code> statement. I am not sure what is wrong. I tried to escape the PHP code then I thought I cannot have PHP code tags with in PHP code.</p>

<p><strong>Here is my code but this does not work:</strong></p>

<pre class="lang-php prettyprint-override"><code>$user =&amp; JFactory::getUser();
if ($user-&gt;guest) 
    echo '&lt;script type="text/javascript"&gt;_gaq.push([\'_setCustomVar\',1,\'User_Status\',\'Guest\',1])&lt;/script&gt;';
    echo '&lt;script type="text/javascript"&gt;_gaq.push([\'_setCustomVar\',2,\'UserID\',\'GuestUser\',1])&lt;/script&gt;';
} else {
    echo '&lt;script type="text/javascript"&gt;_gaq.push([\'_setCustomVar\',1,\'User_Status\',\'LoggedIn\',1])&lt;/script&gt;';
    echo '&lt;script type="text/javascript"&gt;_gaq.push([\'_setCustomVar\',2,\'UserID\',\' "echo $user-&gt;id "\', 1])&lt;/script&gt;';
}
</code></pre>

<p>Can you please help?<br>
Many Thanks<br>
Jai</p>
