chevron_right
chevron_right
JavaScript (Standalone) Integration
How-To/Instructional

JavaScript (Standalone) Integration

Last Updated over a month ago
Article Navigation
Introduction
Instructions
Troubleshooting
Contact Information for Further Assistance

Introduction

Connecting to Ezoic via JavaScript (sometimes called "standalone" integration) is quick and simple, providing publishers with complete control and customization. This integration method is compatible with all site builds and involves inserting a small piece of JavaScript code into your website's HTML, which allows Ezoic to manage and optimize ad placements on your site. In this article, we will provide a step-by-step guide on how to integrate Ezoic using the JavaScript method.

Instructions

  1. Make sure you have created an Ezoic account. If you haven’t done so already, you can do that here.
  2. Connect with your Ezoic Onboarding Specialist if you need help setting up ads.txt or accepting the Google MCM invite.


Setting Up Ads

Connecting your site to Ezoic is a simple process that involves adding a few lines of code to your site. While waiting for Google Ad Manager approval, we recommend getting set up in a staging or dev environment to ensure your ad placements are set up properly and ad loading is confirmed.

This guide will walk you through the steps to implement EzoicAds on your site.

In order to implement EzoicAds, you will need to create ad placements on your site. These ad placements will be used to define the ad locations on your site where Ezoic ads will be displayed.

You can create ad placements in your Ezoic Dashboard, or you can work with your Ezoic Onboarding Specialist to create the ideal ad placements for your site.

Add the Ezoic Privacy Script (this presumes you're using Ezoic's Consent Modal. If using a third-party modal, follow the steps outlined here) and Header Script at the very top of the <head> tag (for quicker ad setup and delivery, we recommend inserting these header scripts within the <head> tag. If placing them in the head is not feasible, the next best option is to position them at the very top of the <body> tag.). Please ensure you load the privacy script before the header script.

<script src="https://the.gatekeeperconsent.com/cmp.min.js" data-cfasync="false"></script>
<script async src="//www.ezojs.com/ezoic/sa.min.js"></script>
<script>
  window.ezstandalone = window.ezstandalone || {};
  ezstandalone.cmd = ezstandalone.cmd || [];
</script>

This code will be called for each ad location. It is important to note that the 3-digit 101 ID represents a specific ad location, and each ad location will have a different 3-digit ID. Ad codes will be generated in your EzoicAds Dashboard.

Each ad location will have the following structure:

<div id="ezoic-pub-ad-placeholder-101"></div>
<script>
    ezstandalone.cmd.push(function() {
        ezstandalone.showAds(101)
    });
</script>

Insert this code for each ad location on your site.

DO NOT add any styling to the actual placeholder div. Adding styles or reserving space for the ad may end with undesired results (e.g. if a placeholder is not chosen by our system, there may be empty space on the page).

Calling ezstandalone.showAds() without defining a placeholder value will call the function for every placeholder that exists on that page.


Dynamic Content

If your website's content loads or changes dynamically, additional configuration may be required. See here for further instructions: https://support.ezoic.com/kb/article/my-content-loads-or-changes-dynamically-can-i-still-use-ezoic

Hybrid Integration is when a site integrates through name servers or Cloudflare, while using the client-side code snippet to call for ads. The benefit of the hybrid integration is that it enables Ezoic's other products (e.g. Site SpeedSEO) with the ability to load ads dynamically. See here for further instructions: https://support.ezoic.com/kb/article/hybrid-integration


Humix Videos

The Embed Code Generator from your Humix Dashboard can be used to add our Video Player to your website.


Advanced

EzoicAds provides advanced features that allow publishers to fine-tune the behavior of the ad library. These features can be used to customize the behavior of the ad library to better suit the needs of your site. See here for further instructions: https://support.ezoic.com/kb/article/javascript-standalone-integration-advanced-features

Troubleshooting

When setting up EzoicAds on your site, it's important to ensure that everything is functioning properly. We provide a built-in JavaScript Integration Debugger that allows you to quickly diagnose issues with your ad setup. Below is a step-by-step guide on how to use this debugger and interpret its outputs.

To activate the debugger, simply append the following query parameter to the URL of the page where your EzoicAds are integrated:

ez_js_debugger=1

For example:

https://www.yourwebsite.com?ez_js_debugger=1

Once the query parameter is added and the page loads, a green modal dialog will appear at the bottom center of the screen. This is the JavaScript Integration Debugger.

The debugger modal contains several key pieces of information that will help you troubleshoot your setup. Here’s a breakdown of the information provided:

  • Script Detection: The debugger will check if the Ezoic script is correctly included on your page. If the script isn't found, you'll see an error message. Ensure that the Ezoic script tag is placed in the right location on your page.

  • Placeholder Detection: The number of defined placeholders on your page will be displayed. This helps verify whether the placeholders have been successfully recognized by the Ezoic system.

  • Ad Status: For each placeholder, the debugger will indicate whether an ad has been successfully rendered. It shows:

    • Whether an ad is assigned to a specific placeholder.
    • If a request was sent to Ezoic to retrieve an ad for that placeholder.
  • Request Success: The debugger also monitors whether the ad request was sent successfully. If there’s an issue, the modal will display error details to help identify the root cause (e.g., network problems, misconfiguration).

The information provided in the debugger modal is invaluable for diagnosing common issues such as:

  • Ads Not Displaying: Check the placeholder detection and ad status to ensure placeholders are defined and ads are assigned.

  • Ad Requests Failing: If ad requests aren't being sent or are failing, the debugger will provide error messages that point to potential misconfigurations.

  • Script Loading Issues: If the script isn’t properly loaded, verify that the script tag is present in your source code and correctly configured.

Contact Information for Further Assistance

If you need further assistance with JavaScript (Standalone) Integration, please log in via https://support.ezoic.com/ to make use of our dedicated resources for support. We're here to help!

× Enlarged Image

Loading ...