Hi i have added the necessary code in the head of theme.liquid, but I am unable to add it to checkout(additional scripts are discontinued)->
The order status page now customizes with customer events and apps that are configured in the editor. You can apply to use discontinued additional scripts until December 31, 2024.
Instead of checkout additional script you may use custom pixel to install GTM script and trigger the purchase event in Google tag manager GTM.
For datalayer you can use stape server side for purchase event
or
Create a custom datalayer that would be compatible with your website (recommended)
Once you have datalayer installed on custom pixel and all ecommerce events on GTM datalayer you can track any ecommerce events including purchase with all event parameters like (value, currency and transaction ID)