Skip to content

Commit bc62388

Browse files
authored
Reintroduce the stickybox on wide screens (#604)
Alternates between using the stickybox placement and the footer placement on unknown themes. It also adds an ID to the stickybox placement so we can see performance of it. As written, this introduces a random element which may not be desirable. We could instead introduce the stickybox only on very wide screens (say >=1600px) or we could base it on the title of the project or something like that to make it deterministic. I'm open to suggestions. > // TODO: Check this placement on the dashboard, > // and see how this is performing. The footer placement is performing very well at ~4x the CTR with ~50% the view rate vs. previously. Ref: #562
1 parent 5eb6b72 commit bc62388

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/ethicalads.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,22 @@ export class EthicalAdsAddon extends AddonBase {
198198
if (elementToAppend) {
199199
elementToAppend.append(placement);
200200
}
201+
} else if (window.innerWidth > 1300 && Math.random() > 0.5) {
202+
// https://ethical-ad-client.readthedocs.io/en/latest/#stickybox
203+
placement.setAttribute("data-ea-type", "image");
204+
placement.setAttribute("data-ea-style", "stickybox");
205+
placement.setAttribute("id", "readthedocs-ea-image-stickybox");
206+
this.addEaPlacementToElement(placement);
207+
// `document.body` here is not too much relevant, since we are going to
208+
// use this selector only for a floating stickybox ad
209+
const elementInsertBefore = document.body;
210+
elementInsertBefore.insertBefore(
211+
placement,
212+
elementInsertBefore.lastChild,
213+
);
201214
} else {
202215
// Default to a text ad appended to the root selector when no known placement found
203216
placement.setAttribute("data-ea-type", "text");
204-
// TODO: Check this placement on the dashboard,
205-
// and see how this is performing.
206217
const docToolName = docTool.getDocumentationTool();
207218
const idSuffix = docToolName ? `-${docToolName}` : "";
208219
placement.setAttribute("id", `readthedocs-ea-text-footer${idSuffix}`);

0 commit comments

Comments
 (0)