There are cases in which Google Search Console, Magento Security Tool or any other service ask to verify you to be the owner of the site and confirm it by adding a code to the  Page <head> tag. Or you need to add some JavaScript code to <head> tag to enable integration with e.g. Hotjar or Zopim Live Chat / Zendesk Live Chat.

Watch this short video in order to learn how to add custom code to the Magento <head> HTML tag or follow the step-by-step instructions below.

In order to add custom code to the HTML <head> in the Magento 2 take the following steps:
1. Navigate to Admin Panel > Content > Configuration.

Magento 2 Custom Code, Head Tag

2. Choose the store view you want the head tag to be changed on or select Global in order to change it on every store view.

Magento 2 Custom Code, Design Configuration

3. Find the HTML Head section and add your code in the Scripts and Style Sheets field.

Magento 2 Custom Code,Scripts and Style Sheets

Once the changes have been performed don't forget to press the Save Configuration button and flush Magento Cache.

Magento 2 Custom Code, Save Configuration