Getting started
Prerequisites
Make sure placeholders are created via the Ezoic dashboard. See our support article to learn more about placeholders and how to create them.
Load Standalone library
Load the standalone library by adding this script to the <head>
of the page.
1<script async src="//www.ezojs.com/ezoic/sa.min.js"></script>
This will load the ezstandalone
global object and run any queued functions.
Adding Placeholders
To add a placeholder to the page, create a div
element where the ad should be. The element's id attribute should be the ID of the placeholder with prefix ezoic-pub-ad-placeholder-
.
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).
For example, to add a placeholder with the id 103, the HTML would look similar to this.
1<body>
2 <div id="ezoic-pub-ad-placeholder-103">
3 </div>
4</body>
Defining Placeholders
Defining placeholders tells ezstandalone which placeholders are available to determine the optimal setup.
Pass all the placeholders that exist on the page to the ezstandalone.define
function with the following code.
1<script>
2 window.ezstandalone = window.ezstandalone || {};
3 ezstandalone.cmd = ezstandalone.cmd || [];
4 ezstandalone.cmd.push(function() {
5 ezstandalone.define(102,103,104);
6 });
7</script>
Note: example is assuming placeholders 102
, 103
, and 104
were created through the dashboard and exist on the page.
ezstandalone
.
Calling For Ads
After defining the placeholders, enable standalone by calling ezstandalone.enable()
. This will fetch optimizations from our servers.
The following is what the code should look like after defining and enabling the placeholders.
1<script>
2 window.ezstandalone = window.ezstandalone || {};
3 ezstandalone.cmd = ezstandalone.cmd || [];
4 ezstandalone.cmd.push(function() {
5 ezstandalone.define(102,103,104);
6 ezstandalone.enable();
7 });
8</script>
Note: this will call for the ad code of the potential placeholders 102
, 103
, and 104
. In order to have the ads show, display must be called.
Displaying ads
In order to display ads, call ezstandalone.display()
after defining and enabling the placeholders.
1<script>
2 window.ezstandalone = window.ezstandalone || {};
3 ezstandalone.cmd = ezstandalone.cmd || [];
4 ezstandalone.cmd.push(function() {
5 ezstandalone.define(102,103,104);
6 ezstandalone.enable();
7 ezstandalone.display();
8 });
9</script>
Setup Complete
Once all steps are done, a basic version of standalone is setup, and pages are ready to show ads!