# Joomla

Source: https://docs.ezoic.com/docs/ezoicads/platforms/joomla/


This page covers where the standard [header scripts](/docs/ezoicads/integration/) and [ad snippets](/docs/ezoicads/implementation/) go on a Joomla site. The code itself is the same as on any other site.

## Before you paste any code

Joomla's default editor (TinyMCE) removes `<script>` tags when you save. The module or article then saves without your code, and nothing shows up on the page.

Before pasting Ezoic code into a module or article, switch your editor to **None** or **CodeMirror**:

1. Go to **Users > Manage**, open your user, and select the **Basic Settings** tab.
2. Set **Editor** to **Editor - None** or **Editor - CodeMirror** and save.

Also check that your user group is allowed to save scripts: in **System > Global Configuration > Text Filters**, your group (for example Super Users or Administrator) should be set to **No Filtering**.

## Step 1: Add the header scripts

The header scripts must load on every page, as high in the `<head>` as possible. Use one of these options.

**Template custom code field.** Most modern Joomla templates and frameworks (YOOtheme Pro, Helix Ultimate, Gantry, Astroid, T4) have a custom code field in the template settings. Go to **System > Site Templates**, open your active template style, and look for a field that outputs in the `<head>`. Paste the header scripts there.

**Custom code plugin.** If your template has no such field, install a "custom code in head" system plugin from the Joomla Extensions Directory, enable it under **System > Manage > Plugins**, and paste the header scripts into its head field. This survives template updates.

**Template `index.php`.** As a last resort, open your template's `index.php` under **System > Site Templates** and paste the scripts directly above `</head>`. Template updates can overwrite this edit, so use a child template if your template supports one.

## Step 2: Add ad snippets

Use the ad code from [Step 3: Ad Placements](/docs/ezoicads/implementation/). We recommend [placement IDs](/docs/ezoicads/implementation/#placement-ids) for most established sites: put a placeholder `div` where each ad should appear, and one `showAds` call with the page's placement IDs at the bottom of the page.

```html
<div id="ezoic-pub-ad-placeholder-101"></div>
<!-- ... page content ... -->
<div id="ezoic-pub-ad-placeholder-102"></div>

<script>
    ezstandalone.cmd.push(function () {
        ezstandalone.showAds(101, 102);
    });
</script>
```

The [quick start](/docs/ezoicads/implementation/#quick-start) snippet also works; Step 3 compares the two. If you cannot paste code at the exact spot (for example a builder layout you cannot edit), the [ShowAds Builder](/docs/ezoicadsadvanced/showads-builder/) can generate a quick start snippet that places its ad at a named location or after a page element.

Where you paste the code depends on what renders your pages. Below, "snippet" means the placeholder `div`s and the `showAds` call.

### Pages built with a page builder

If a page builder renders your pages, put the snippet inside the builder. Check by viewing the source of an article: a comment like `<!-- Builder #page -->` or `<!-- Builder #template-... -->` means YOOtheme Builder is rendering that page.


When a page builder renders a page, Joomla does not use your `com_content` template overrides for it. Code pasted into an override file such as `html/com_content/article/default.php` never reaches the page.


**YOOtheme Pro:**

1. Open the YOOtheme Customizer and go to **Templates**.
2. Open the template that renders the page type you want ads on, for example your article or category template.
3. Add an **HTML** element where the ad should appear, paste the ad snippet, and save.
4. For pages built directly with the Builder (such as a homepage), edit that page's layout and add the HTML element there.

Other builders (SP Page Builder, Helix Ultimate, Gantry) work the same way: add a raw HTML or code element to the layout or template that renders the page.

### Standard Joomla pages

If no builder is involved, use any of these:

- **Custom modules.** Go to **Content > Site Modules > New > Custom**, paste the snippet, choose a **Position**, and under **Menu Assignment** pick the pages it should appear on. The position must be one your template actually shows on the page; check by viewing the page source after saving.
- **Inside an article.** Edit the article, switch to code view, and paste the snippet where the ad should go. Good for one-off placements.
- **Template overrides.** In **System > Site Templates**, open your template, use **Create Overrides** for `com_content` (article, category, or featured), and paste the snippet into the override file at the point you want the ad. Category blog pages use `blog.php`, not `default.php`.

A module or element that holds the `showAds` call must appear on every page that has placeholders, and list every placement ID on that page.

## Switching from nameserver integration

If your domain currently uses Ezoic nameservers, Ezoic is already adding the privacy (consent) scripts to your pages. Adding them again before you switch makes the consent banner load twice, which can lock visitors in Europe out of your site. Switch in this order:

1. Set up [ads.txt](/docs/ezoicads/adstxt/) on your own host.
2. Add the header scripts from Step 1 **without** the privacy scripts.
3. Add your ad snippets from Step 2.
4. Test the JavaScript integration on its own: open any page with `?ez_js_preview=1` added to the URL (for example `https://example.com/my-article/?ez_js_preview=1`). That page loads without Ezoic's nameserver integration, so it shows exactly what your Joomla code does. Check an article, a category page, and your homepage, adding the parameter to each URL. Test from outside Europe, since the consent banner is not on the page yet.
5. Point your nameservers back to your host.
6. Add the privacy scripts above the header scripts, using the same method as Step 1.

## Troubleshooting

**The ad snippet is not in the page source.** Your code was stripped or is in a place Joomla does not render. Check the editor setting above, then check whether a page builder renders that page.

**The module saved but nothing appears.** The module position may not exist in your template's layout, or the module's **Menu Assignment** excludes the page. Try a different position or assign it to all pages to test.

**Ads stopped after a template update.** The update overwrote edits to `index.php` or override files. Use a template custom code field, a plugin, or builder elements instead.

