The approach to integrating Ezoic ads with ReactJs or NextJs based websites is different from traditional request/response based websites. This article explains how to integrate Ezoic with ReactJs or NextJs based websites. This method works for all the Ezoic ads embedded on the page. Including the ads embedded in a post body and rendered as
Check out our other articles on analytics and Google Adsense.
Next js google tag manager: 3 ways to use Google analytics in Nextjs
React js google tag manager: React Google analytics problem solved
How to use google adsense in Next Js
If you integrate Ezoic with Nextjs in the traditional way, the ads will show in the initial page load. Any internal navigation that happens with the
We assume that your page is rendered with embedded ad units. Ad units are divs with a specific id with a unique ad id appended to it.
This appended id is used to identify the ad unit and is referred to as placeholders. In the above ad unit, 109 is the placeholder.
Select a page resource common to all the pages of your application. That can be the
The next step is to insert the Javascript code that define and enable all the ads embeded in the page. The ezstandalone is a function defined in the file
useEffect(() => {
ezstandalone.define(109,110);
if (!ezstandalone.enabled) {
ezstandalone.enable();
ezstandalone.display();
}
else {
ezstandalone.refresh();
}
},[])