You can track add to cart, purchase or any other events and call custom JS script / pixel by setting up GA (Google Analytics) and GTM (Google Tag Manager) on your Shopify store.
Here's how you can do it -
Step 1: Setup GA and GTM on your store. Follow the steps mentioned here.
Step 2: Define a trigger in GTM which will fire on all add to cart events using button class element - shopify-buy__btn . Define a custom html tag that you want to fire on add to cart events.
Let me know if you need any help.