Skip to content

Add tracking code to override success.phtml

I’ve create a custom module to collect customer data and return it back to Google at success page.

In my module success.phtml :

<?php
/** @var ChicGoogleBlockSuccess $block */
?>
<h1><?= $block->getGrandTotal() ?></h1>

<script>
  gtag('event', 'conversion', {
      'send_to': 'AW-11109313262/QKkuCMyiuqAYEO7VqrEp',
      'value': '',
      'currency': 'SAR',
      'transaction_id': ''
  });
</script>

Now at success page the grand total already appear but the script is not available when I check page source through my browser !

enter image description here

Could you please advise what I’ve to do ?