Why Use Manual JavaScript Integration?
While WordPress users benefit from the automation of the Ezoic WordPress Plugin, manual JavaScript integration is the best choice for:
-
Non-WordPress CMS: Sites built on custom-coded frameworks.
-
Precision Control: Publishers who want to define exact ad locations within their unique HTML structure.
-
Minimalist Footprint: Users who prefer to keep their site backend "clean" by inserting code directly rather than managing additional plugins.
Prerequisites
Before you begin, ensure:
-
You have an active Ezoic account.
-
You have completed the Google MCM application in your dashboard.
-
Your Ads.txt is configured and shows a "Healthy" status.
Step 1: Add the Header Scripts
To initialize the connection, place these two lightweight scripts at the very top of your <head> tag. This ensures the engine is ready to serve ads as soon as the page begins to load.
1. Privacy Script
This script manages Consent Management and must load first to ensure your site remains compliant with global privacy regulations.
<script data-cfasync="false" src="https://cmp.gatekeeperconsent.com/min.js"></script>
<script data-cfasync="false" src="https://the.gatekeeperconsent.com/cmp.min.js"></script>
2. Ezoic Header Script
This snippet loads the core Ezoic library asynchronously to ensure zero impact on your page load speed.
Step 2: Insert Ad Placeholders
Placeholders are simple HTML containers that tell the AI exactly where it is permitted to consider showing an ad. You generate these unique IDs (e.g., 101, 102) in your EzoicAds Dashboard.
For every location you want to monetize, insert the following code:
<div id="ezoic-pub-ad-placeholder-101"></div>
<script>
ezstandalone.cmd.push(function () {
ezstandalone.showAds(101);
});
</script>
Step 3: Verification & The Ramp Up Period
Once the scripts are active and Google has approved your MCM status, your ads will go live automatically. Ezoic will then begin the Ramp Up Period, where the AI collects data to maximize your long-term EPMV.
Using the JavaScript Debugger
To confirm your setup is optimal, append ?ez_js_debugger=1 to any URL on your site. A diagnostic modal will appear to confirm:
-
Script Detection: Verifies the Ezoic library is loading correctly in the browser.
-
Placeholder Count: Ensures the system sees all the locations you've created.
-
Ad Status: Shows real-time request and fill data for each position.
Advanced Documentation
Advanced documentation regarding javascript integration can be found in our Developers Documents.