Step 1: Log in to the Magento Admin Panel
Access your Magento admin panel by entering the URL provided during your Magento installation (e.g., yourdomain.com/admin).
Step 2: Navigate to Content Management
On the admin dashboard, go to Content > Design > Configuration.
Step 3: Edit the Store View
Find the store view you want to edit in the list and click on the Edit link on the right side of the screen.
Step 4: Access the HTML Head Section
In the edit view, scroll down to find the HTML Head section. This section allows you to add custom scripts or styles to your site's head section.
Step 5: Add Your Script
In the Scripts and Style Sheets text area, add your custom script. Make sure to wrap your JavaScript code with <script>
tags. For example:
<script> //
Your custom script here
</script>
Step 6: Save Configuration
After adding your script, scroll to the top or bottom of the page and click on the Save Configuration button to apply your changes.
Step 7: Clear Cache
Magento caches a lot of its content to improve performance. After making changes, go to System > Cache Management. Select all caches and apply the Refresh action to make sure your changes are reflected on the frontend.
Step 8: Verify
Visit your website and inspect the page source to verify that your custom script has been added to the header.