There are many apps in Shopify app store that allow adding code. Many of them are paid. The app "HT Script" has free plan which allows you to add code to the header, which is exactly what needed in order to add retargeting script to you website.
Enter the link to the app and then click "Add app".
Then click "Install app".
Paste the code you got from your dashboard to the following box: