Skip to main content
How to Add Custom JavaScript Code in Divi

Learn how to add JavaScript code in Divi globally or on an individual page, post, project, or Woo Product.

Updated over a week ago

While using the Divi theme, custom JavaScript code such as Google Analytics, Google Adsense code, or any other JavaScript code can be added:

  • Globally, in the Integration Tab

  • Individually to any page, post, project, or Woo product

Add custom JavaScript code globally

  1. Go to WordPress Dashboard → Divi → Theme Options

  2. Click on the Integration Tab

  3. Based on your code, you have the flexibility to include it either inside the page's <header> HTML tag or inside the page's <body> HTML tag:

    1. <head> section - if you want the code to run globally on your website. Usually, this section is used for codes that should run on any page of your website

    2. <body> section - if you want the code to run globally on your website. Usually, this section is used for Google Tracking code and/or Google Analytics code.

    Divi Integration tab

Add custom JavaScript code individually to a page, post, project, or Woo Product

  1. Enabled the Visual Builder on the page, post, project, or Woo product where the custom JavaScript code should run

  2. Insert the Code module into the layout

  3. Place the custom JavaScript code in the Code module's Content Tab → Code

    The Divi's Code module

Add custom JavaScript code individually to a page, post, project, or Woo Product using the Theme Builder

  1. From WordPress Dashboard, go to Divi → Theme Builder

  2. Create a new template or Edit an existing template's header

  3. In the Header's template part, add the Code module

  4. Place the JavaScript code in the Code module's Content Tab → Code


Related Articles

Did this answer your question?