I am trying to get the info from a PHP variable in to JavaScript while in the PHP if
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.
Here is my code but this does not work:
$user =& JFactory::getUser();
if ($user->guest)
echo '<script type="text/javascript">_gaq.push([\'_setCustomVar\',1,\'User_Status\',\'Guest\',1])</script>';
echo '<script type="text/javascript">_gaq.push([\'_setCustomVar\',2,\'UserID\',\'GuestUser\',1])</script>';
} else {
echo '<script type="text/javascript">_gaq.push([\'_setCustomVar\',1,\'User_Status\',\'LoggedIn\',1])</script>';
echo '<script type="text/javascript">_gaq.push([\'_setCustomVar\',2,\'UserID\',\' "echo $user->id "\', 1])</script>';
}
Can you please help?
Many Thanks
Jai
$user =& JFactory::getUser();
, shouldn't this be$user = &JFactory::getUser();
– asifsid88 Feb 6 at 12:15