When i post this script in the functions.php file it points to error, can you see whats wrong?

<?php if(is_product()) {?>
<script>
analytics.track('Product Viewed', {
  'ecommerce': {
    'detail': {
      'products': [{
        'name': '<?php echo the_title(); ?>',
        'id': '<?php echo the_ID(); ?>',
        'brand': 'test',
      'category':'test'
       }]
     }
   }
});
</script>
<?php }?>

Read more here: Woocommerce: When i post this script in the functions.php file it points to error, can you see whats wrong?


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: