Magento 2 HTML <head> is a place where you put any custom code to verify you're the website owner or add some custom integration with Google Tag Manager, Google Analytics or any other tracking system. In this guide, you'll learn how to do that in a matter of a few clicks.

Add Ownership Verification to Head

To add custom code to the HTML <head> in Magento:

1. Navigate to Admin Panel > Content > Configuration.

2. Choose the store view you want the head tag to be changed on or select Global 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

Don't forget to press the Save button once you finish and flush cache

Watch this short video to learn how to add custom code to the Magento <head> HTML tag.

Add Tracking Scripts to Head

If the code you add to the HTML head is for data tracking, you need to know that loading that script will influence your store performance. Thus, if you want to set up data tracking with Google Tag Manager or Facebook Pixel, try setting this up with the extension to optimize loading speed.