Skip to content

undefined dataLayer variables GTM

I’m using GTM to track purchase event from Snapchat.
I’ve created a tag in GTM and it’s fired but I got undefined variable !
I’m using this script in success.phtml

<script>
  dataLayer.push({
    'event':'purchase',
    'order_value':<?php echo $totall;?>,
    'order_id':<?php echo ($block->getOrderId()) ?>,
    'enhanced_conversion_data': {
      "email": <?php echo $email;?>,  
      "phone_number": <?php echo $phone;?>
    }
  })
</script>

The code above works fine when I check it through the browser :
enter image description here

But unfortunately the variables undefined !

I’ve tried to create a custom event trigger as following but it’s not fired:
enter image description here

Looking for you kind support.