Hi,
You can add that code in the file "after_end" of the view "checkout" via the menu Display>Views provided that you didn't enter a "return URL" in your payment method and that your payment method redirects you to the payment gateway at the end of the checkout for the payment.
If it's not the case, then you'll want to add the code int he file "end" of the view "checkout".
In both cases, you can find the products in the order in the array $this->order->products since you can have several products. So your code will have to be something like that:
<script language='javascript'>
<?php foreach( $this->order->products as $row) { ?>
gtag('event', 'purchase', { 'event_category' : 'ecommerce', 'event_label' : '<?php echo $row->order_product_name; ?>' });
<?php } ?>
</script>