php和js脚本相结合

I'm trying to include the following code in my wordpress, sending the username to Heap Analytics, if user is logged in.

<?php if (is_user_logged_in()) { ?> 
<script>
var usr_heap = <?php $current_user = wp_get_current_user(); echo $current_user->display_name; ?>;
heap.identify({'Wordpress Username': usr_heap});
</script> 
<?php } ?>

Any idea what I'm possibly doing wrong? Probably a very simple question... Thanks for your help! V

The value of usr_heap is a string, so there must be " " around the sting value

<?php if (is_user_logged_in()) { 
$current_user = wp_get_current_user();
?> 
<script>
var usr_heap = "<?php echo $current_user->display_name; ?>";
heap.identify({'Wordpress Username': usr_heap});
</script> 
<?php } ?>