Englishen
Your cart: 0
Cart Subtotal: €0.00

How to add JavaScript code through administration - Magento

There are several ways to include custom JavaScript code in the header of your page. In this article, I will present the easiest way - a method that allows us to do this via the Magento 2 administrative interface without requiring programming skills or additional access. This method can be used for integrating third-party services such as live chat, monitoring tools, and similar.

Adding JavaScript code to a Magento 2 store

Content > Design > Configuration > Edit > HTML Head > Scripts and Styles

Step-by-step guide for beginners

Although it seems simple, this can cause some questions for those who are not very familiar with Magento. Therefore, I present a complete guide, step by step, on how to add a code snippet:

  1. The first thing we need to do is open the administrative dashboard and log in.
  2. Then in the Magento menu, go to: Content > Design > Configuration
  3. Click the "Edit" link for the store view. This will usually be the first item if your Magento has only one store view. If there are more, select the website where you want to include your script.
  4. Click on the "HTML Head" tab -> "Scripts and Styles" or "Footer" -> "Miscellaneous HTML".
  5. Enter your code in the field and click the "Save Configuration" button.

If any other code is already present, your code will be entered after all other code.

Troubleshooting display issues

The code was added, but there are no changes in the store. Caching issue - Your page is likely cached, and you need to clear it. You can clear the store cache here: Magento Admin > System > Cache Management > Select All > Refresh > Submit

Adding JavaScript code to a Magento 1.9 / OpenMage store

The process of adding custom JavaScript code to the page header is similar for Magento 1.9 or OpenMage. Here is a simple guide on how to do it:

  1. First, open the administrative dashboard and log in.
  2. In the Magento menu, navigate to: System > Configuration > General/Design.
  3. Click on the "HTML Head" tab and find the "Miscellaneous Scripts" option or "Footer" and "Miscellaneous HTML".
  4. Enter your code in the appropriate field and click the "Save Configuration" button.

With this, you have successfully added custom JavaScript code to the header of your Magento store. This process is easy and allows you to integrate additional functionality or services into your store without programming skills.

Troubleshooting display issues

The code was added, but there are no changes in the store. Caching issue - Your page is likely cached, and you need to clear it. You can clear the store cache here: Magento Admin > System > Cache Management > Select All > Refresh > Submit

Need to add code with events?

In this case, you will need to add a module because dynamic events cannot be added directly to the fields. For this purpose, we have developed several different modules, such as the Google Analytics 4 (gtag) module for Magento 1.9 / OpenMage.

Stop browsing. Start selling. Contact me now at anze@degriz.net.

Access Premium Content for Free

Subscribe to our newsletter and get free access to premium content. Discover valuable insights and exclusive resources available only to our subscribers.

Privacy Policy: Newsletter Subscription

By entering your email address, you are subscribing to the newsletter, through which Degriz will inform you about new online and in-store offerings, marketing activities, and other promotions.

By subscribing to the newsletter, you are also enrolled in the benefits database that Degriz offers to its users.

For the newsletter subscription, Degriz d.o.o. collects the following information: email address, IP address, and if you subscribe as a registered member, your name, surname, address, and phone number.

After submitting the form with your email address, you will receive a confirmation message at the specified address – by confirming this, you will be subscribed to the Degriz newsletter until you unsubscribe (so-called opt-in approval). You can request, in writing or by clicking the Unsubscribe button in the newsletter, that the data controller permanently or temporarily stops using your personal data for direct marketing purposes. Your request will be fulfilled within 15 days of receiving it, as prescribed by law. You can also request the transfer or access to your data.

Degriz d.o.o. is committed to protecting your data in accordance with the legislation governing personal data protection.

The sender of the newsletter and controller of your personal data is: Degriz, d.o.o., Gorica pri Šmartnem 45a, 3000 Celje, SI 67287743

Check out the full Privacy Policy

Newsletter

My name is Anže, and I am a Magento certified expert in solutions and a creator of multiple award-winning online stores.

I am the architect behind all Degriz projects. You will surely come across me if we collaborate. Even though the phone keeps ringing, you can always tap me on the shoulder if you need advice regarding online stores and their functioning.

I specialize in building custom online stores and I am a master of unique techniques to enhance conversion on your website.

© 2010 - 2026 Degriz. All rights reserved. Built with love on Magento.
Partial use of the content is permitted with mandatory attribution. The content is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0) or under our own license.