How to add JavaScript to WordPress

0.00
20:56
438
I need to add javascript to the website on Wordpress (tracking code). But I don't know how to do that. Could you please tell me how I can add Javascript to Wordpress website? PS. I am not tech savvy person.
Related CMS:
22:08
Hi, Tony. There are few ways how you can add JavaScript code to Wordpress:

Add JavaScript code directly to your theme files


This way is not ideal, because when your template will be updated, changes that you've done in theme files will be overwritten. This is why it is strongly recommended to create a child theme. We will describe this process in a separate article. In case if you will choose this option: go to Appearance --> Editor. Then select file where you need to add JavaScript code (if you need to add it to the head section of your website — open header.php file). Then insert your tracking code and save this file. You can also use FTP client and do the same on your local computer. Don't forget to make a backup before making changes.

Add JavaScript code to Wordpress using plugins


There are a lot of different plugins which allow you to add custom JS or CSS code to your Wordpress based website. I personally like «Insert Headers and Footers» plugin. It allows you to add any JavaScript code to the header or footer of your Wordpress website.

Other options


Some premium themes have special section in Theme options where you can add custom JS code.

Write a comment

Loading...