Hi,
If you've added the code:
<script>
pintrk('track', 'addtocart', {
value: 10.00,
order_quantity: 1,
currency: 'USD'
});
</script>
somewhere on a Joomla website in a PHP file and you want that JS code to be in the header of the page, then you can replace it by :
$document = JFactory::getDocument();
$document->addScriptDeclaration("
pintrk('track', 'addtocart', {
value: 10.00,
order_quantity: 1,
currency: 'USD'
});
");
This won't replace dynamically the data from the the products on the page.
In order to track everything (products, carts, orders), it requires the development of a plugin with hundreds of lines of code, similarly to what we did with the GA4 and Matomo plugins on our marketplace.
It's possible, but it's not something I can do for you here and if you're not familiar with PHP, you won't be able to do it either.