...
This integration guide applies if AdEngine needs to run on Single-Page-Application (SPA for short) type of pages. When the head code is not reloaded, and only content of the page changes due to user action.
This guide is based on react.js implementations. It should fit all otherothers, however, please take into consideration that some elements of integration might differ.
For this integration guide, we assume the example of a website with the following two ads on every page:
...
The head section modifications are the essential part of this integration. Without adding the AdEngine script and configuration to the head, the ads won't render. In SPA type of pages, it's very important due to the specifications of those pages where the head config is not reloaded.
...
This is the easiest way to integrate AdEngine. It will load the site specific AdEngine configuration and display ads automatically in the selected div - elements, when the user first enters the page.
...
Replace **site.domain** with the actual site domain
Place the script at the very top of the header to ensure the best performance
If Google Analytics is used, place the AdEngine tag after the Google Analytics tag
Keep the correct order of the tags: first configuration and then loading of AdEngine
...
The page body needs to define div elements which that will be filled with ads. They need to be placed where the ad should be displayed.
The div elements should reserve the maximum width and height of the displayed ad to prevent [Cumulative Layout Shift][cls] (CLS). If you are using ad labeling, reserve an additional 15px of height for the label. To reserve the proper space please consult your account manager to get the exact ad sizes.
...
Code Block |
---|
const MyPage = () => { // the useEffect hook of functional React is equivalent to componentDidMount of class-based React useEffect(() => { if (window.adngin && window.adngin.adnginLoaderReady) { // when adnginLoaderReady boolean is true, it is safe to access command queues like adngin.queue or googletag.queue adngin.queue.push(() => { // it is recommended to auction only ONCE, so please gather all required ad unit names; // or do not pass anything if all ad units are to be re-auctioned const units = getAdUnitNamesForCurrentPage(); adngin.cmd.startAuction(units); }); }); }); }; |
Details about startAuction command can be found here
Testing on a staging page
...
Snigel is using the staging version of AdEngine to deliver previews of new features and enhancements before they are available on in production. This way it is possible to test new features in a safe way.
...