Implement with Magento 2.x
Go to your Admin Panel
Go to Content, then Configuration
Select the store view you would like to add the code to, or pick Global if you would like to change it on every store view
Go to the HTML Head section and find the field Scripts and Stylesheets
Add the script:
Remember to press Save Configuration, then clear the cache to see your update pushed.