Before You Begin
Before you start setting up ads, make sure to contact the Overlayed team to discuss ads on your app. We’ll discuss ad positioning, ad units, and more. It’s crucial to start this process early so that we have time to setup the ads before you start using them.Installation
To start with ads, you’ll need to install the@overlayed/ads
package:
Setup
Electron
On the electron side, for any BrowserWindow or RenderWindow you create and intend to show ads in, you’ll need to call:Under the hood, registerWindow does two things:
- Sets up a link handler to open ads (and block malicious behavior!)
- Sets the user agent of all requests, which removes non-standard portions of the User Agent string which may trigger IVT (invalid traffic).
Preload
Within your electron app’s preload script, you’ll need to add the following import:Render Process
Within the render process, theres a few more things to setup:Initialization
Call theinit
method when your HTML/JS first loads:
Adding the ads script
This script can be added in a variety of ways, for example: With HTML (note thedefer
attribute):