0

I'm using Magento 2.4 and I'm trying to get grand total and customer data variables to be inserted to Google tracking code.

I've followed the link below to create custom module to call $block->getGrandTotal but it's not work ! https://magento.stackexchange.com/a/116922/105485

This is google code which I've to fill it with magento variables :

<script>
  gtag('event', 'conversion', {
      'send_to': 'AW-595825986/_BYQCLj7tr0DEMKqjpwC',
      'value': <?php echo $totall;?>,
      'currency': 'SAR',
      'transaction_id': ''
  });
</script>
<script>
  dataLayer.push({
    'event':'purchase',
    'order_value':'verraible for order value',
    'order_id':'order_id',
    'enhanced_conversion_data': {
      "email": 'yourEmailVariable',   
      "phone_number": 'yourPhoneVariable',
      "first_name": 'yourFirstNameVariable',
      "last_name": 'yourLastNameVariable',
      "street": 'yourStreetAddressVariable',
      "city": 'yourCityVariable',
      "region": 'yourRegionVariable',
      "postal_code": 'yourPostalCodeVariable',
      "country": 'yourCountryVariable'
    }
  })
</script>

1 Answer 1

1

Below link is get order all information from order Id.

https://www.codextblog.com/code-snippet/get-order-information-from-order-id-in-magento-2/

THANKS.

1
  • This is not what I'm looking for
    – Dun7ill
    Commented Aug 7, 2022 at 14:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.