Ads allow you to monetize your overlay, this guide will cover various utilities we provide for managing them.
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:
pnpm i @overlayed/ads
npm i @overlayed/ads
yarn add @overlayed/ads
Setup
Electron
On the electron side, for any BrowserWindow or RenderWindow you create and intend to show ads in, you’ll need to call:
overlayed.ads.registerWindow(browserWindow);
Do not modify the user agent of your Electron application. This includes app.userAgentFallback,
session.setUserAgent, webContents.setUserAgent, and the useragent attribute on <webview>. Ad demand partners
use the user agent to decide whether and what to bid, so changing it can significantly reduce your ad revenue.
Preload
Within your electron app’s preload script, you’ll
need to add the following import:
import "@overlayed/app/preload";
This will automatically execute code that facilitates Overlayed’s communication between the electron process and
rendering process.
Render Process
Within the render process, there are a few more things to set up:
Initialization
Call the init method when your HTML/JS first loads:
import overlayedAds from "@overlayed/ads";overlayedAds.init();
You can call this function as many times as you want, it will only execute once.
Adding the ads script
Use the package helpers to build and mount the script with the correct app domain:
import { getAdsScriptElement } from "@overlayed/ads";const script = getAdsScriptElement({ onError: (event) => { // Add your logging/observability here console.error("Failed to load ads script", event); },});if (script) { document.head.appendChild(script);}
If you need the script URL directly, use getAdsScriptUrl() from @overlayed/ads.
Conclusion
That concludes the required setup for ads. Check out the configuration guide for more information
on how to configure ad units, conditionally disable ads, and more.
Was this page helpful?
{"docsConfig":{"theme":"aspen","$schema":"https://mintlify.com/docs.json","name":"Overlayed","colors":{"primary":"#3489eb","light":"#76a5db","dark":"#1b5eab"},"logo":{"light":"https://mintcdn.com/overlayed/NjkLE7VgHNllkGf9/logo/logo-with-text-dark.webp?fit=max\u0026auto=format\u0026n=NjkLE7VgHNllkGf9\u0026q=85\u0026s=9a95df5e68f6e3a67cd604bc4ffc3436","dark":"https://mintcdn.com/overlayed/NjkLE7VgHNllkGf9/logo/logo-with-text.webp?fit=max\u0026auto=format\u0026n=NjkLE7VgHNllkGf9\u0026q=85\u0026s=0e07d6d4259e69518078b1c07a25ee0c"},"favicon":"https://mintcdn.com/overlayed/lLO1lk9TCoDk13HP/favicon.svg?fit=max\u0026auto=format\u0026n=lLO1lk9TCoDk13HP\u0026q=85\u0026s=fa929ac3b1a7a174cb8e4f266f5db05e","navbar":{"links":[{"href":"https://overlayed.gg","label":"Marketing Site"},{"href":"mailto:support@overlayed.gg","label":"Support"}],"primary":{"type":"button","label":"Dashboard","href":"https://overlay.dev"}},"contextual":{"options":["copy","chatgpt","claude","cursor","vscode","mcp"],"display":"header"},"styling":{"latex":false},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"overlayed","hasAudioNarration":false,"actualSubdomain":"overlayed","customDomains":["docs.overlayed.gg"],"gitSource":{"type":"github","owner":"overlayed-gg","repo":"overlayed-typescript","deployBranch":"main","contentDirectory":"docs","isPrivate":true,"mountPath":"","label":""},"feedback":{"thumbs":true,"edits":true,"issues":true},"entitlements":{},"buildId":"6afcee8995c23b69d00f26c2","clientVersion":"0.0.4248","searchFilterCounts":[{"language":"default","tag":"Docs","count":32},{"language":"default","tag":"Guides","count":22},{"language":"default","tag":"Packages","count":11},{"language":"default","tag":"Supported Games","count":10},{"language":"default","tag":"Essentials","count":7},{"language":"default","tag":"@overlayed/app","count":5},{"language":"default","tag":"Deployment","count":4},{"language":"default","tag":"Logging","count":4},{"language":"default","tag":"Windows","count":4},{"language":"default","tag":"Ads","count":3}]},"assistantConfig":{},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-rbac-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"site-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"starter-pricing","enabled":true,"variant":{"name":"control","enabled":true,"payload":{"type":"string","value":"control"},"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"wildcard-email-auth","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":false},"customCss":[]}
{"page":{"pagePath":"ads/introduction","slug":"/ads/introduction","pageMetadata":{"title":"Overlay Ads","sidebarTitle":"Monetize Your Overlay","description":"Ads allow you to monetize your overlay, this guide will cover various utilities we provide for managing them.","href":"/ads/introduction"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Ads allow you to monetize your overlay, this guide will cover various utilities we provide for managing them.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,p:`p`,pre:`pre`,span:`span`,..._provideComponents(),...props.components},{CodeBlock,CodeGroup,Heading,Warning}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!CodeGroup)_missingMdxReference(`CodeGroup`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsx(Heading,{level:`2`,id:`before-you-begin`,children:`Before You Begin`}),`\n`,_jsx(_components.p,{children:`Before you start setting up ads, make sure to contact the Overlayed team to discuss ads on your app. We’ll discuss ad\npositioning, ad units, and more. It’s crucial to start this process early so that we have time to setup the ads before\nyou start using them.`}),`\n`,_jsx(Heading,{level:`2`,id:`installation`,children:`Installation`}),`\n`,_jsxs(_components.p,{children:[`To start with ads, you’ll need to install the `,_jsx(_components.code,{children:`@overlayed/ads`}),` package:`]}),`\n`,_jsxs(CodeGroup,{children:[_jsx(CodeBlock,{filename:`pnpm`,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`pnpm`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` i`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` @overlayed/ads`})]}),`\n`]})})}),_jsx(CodeBlock,{filename:`npm`,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`npm`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` i`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` @overlayed/ads`})]}),`\n`]})})}),_jsx(CodeBlock,{filename:`yarn`,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`yarn`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` add`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` @overlayed/ads`})]}),`\n`]})})})]}),`\n`,_jsx(Heading,{level:`2`,id:`setup`,children:`Setup`}),`\n`,_jsx(Heading,{level:`3`,id:`electron`,children:`Electron`}),`\n`,_jsx(_components.p,{children:`On the electron side, for any BrowserWindow or RenderWindow you create and intend to show ads in, you’ll need to call:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`overlayed`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`ads`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`registerWindow`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`browserWindow`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`]})})}),`\n`,_jsx(Warning,{children:_jsxs(_components.p,{children:[`Do not modify the user agent of your Electron application. This includes `,_jsx(_components.code,{children:`app.userAgentFallback`}),`,\n`,_jsx(_components.code,{children:`session.setUserAgent`}),`, `,_jsx(_components.code,{children:`webContents.setUserAgent`}),`, and the `,_jsx(_components.code,{children:`useragent`}),` attribute on `,_jsx(_components.code,{children:`\u003cwebview>`}),`. Ad demand partners\nuse the user agent to decide whether and what to bid, so changing it can significantly reduce your ad revenue.`]})}),`\n`,_jsx(Heading,{level:`3`,id:`preload`,children:`Preload`}),`\n`,_jsxs(_components.p,{children:[`Within your electron app’s `,_jsx(_components.a,{href:`https://www.electronjs.org/docs/latest/tutorial/tutorial-preload`,children:`preload script`}),`, you’ll\nneed to add the following import:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"@overlayed/app/preload\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`This will automatically execute code that facilitates Overlayed’s communication between the electron process and\nrendering process.`}),`\n`,_jsx(Heading,{level:`3`,id:`render-process`,children:`Render Process`}),`\n`,_jsx(_components.p,{children:`Within the render process, there are a few more things to set up:`}),`\n`,_jsx(Heading,{level:`4`,id:`initialization`,children:`Initialization`}),`\n`,_jsxs(_components.p,{children:[`Call the `,_jsx(_components.code,{children:`init`}),` method when your HTML/JS first loads:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`3`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`3`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` overlayedAds`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"@overlayed/ads\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`overlayedAds`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`init`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`();`})]}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`You can call this function as many times as you want, it will only execute once.`}),`\n`,_jsx(Heading,{level:`4`,id:`adding-the-ads-script`,children:`Adding the ads script`}),`\n`,_jsx(_components.p,{children:`Use the package helpers to build and mount the script with the correct app domain:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`12`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`12`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`getAdsScriptElement`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"@overlayed/ads\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` script`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` getAdsScriptElement`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`\tonError`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`event`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`=>`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`\t\t// Add your logging/observability here`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`\t\tconsole`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`error`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Failed to load ads script\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`event`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`\t},`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`});`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`script`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`\tdocument`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`head`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`appendChild`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`script`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`If you need the script URL directly, use `,_jsx(_components.code,{children:`getAdsScriptUrl()`}),` from `,_jsx(_components.code,{children:`@overlayed/ads`}),`.`]}),`\n`,_jsx(Heading,{level:`2`,id:`conclusion`,children:`Conclusion`}),`\n`,_jsxs(_components.p,{children:[`That concludes the required setup for ads. Check out the `,_jsx(_components.a,{href:`/ads/configuration`,children:`configuration`}),` guide for more information\non how to configure ad units, conditionally disable ads, and more.`]})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"Overlay Ads","sidebarTitle":"Monetize Your Overlay","description":"Ads allow you to monetize your overlay, this guide will cover various utilities we provide for managing them.","href":"/ads/introduction"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Before You Begin","slug":"before-you-begin","depth":2,"children":[]},{"title":"Installation","slug":"installation","depth":2,"children":[]},{"title":"Setup","slug":"setup","depth":2,"children":[{"title":"Electron","slug":"electron","depth":3,"children":[]},{"title":"Preload","slug":"preload","depth":3,"children":[]},{"title":"Render Process","slug":"render-process","depth":3,"children":[]},{"title":"Initialization","slug":"initialization","depth":4,"children":[]},{"title":"Adding the ads script","slug":"adding-the-ads-script","depth":4,"children":[]}]},{"title":"Conclusion","slug":"conclusion","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"subdomain":"overlayed","siteName":"Overlayed","title":"Overlay Ads - Overlayed","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-10-16T04:51:49.618Z","originalFileLocation":"ads/introduction.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Ads allow you to monetize your overlay, this guide will cover various utilities we provide for managing them.\">\u003cmeta data-mint-head name=\"application-name\" content=\"Overlayed\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/overlayed/9j0jnwVWRyevrtyx/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/overlayed/9j0jnwVWRyevrtyx/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/overlayed/9j0jnwVWRyevrtyx/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/overlayed/9j0jnwVWRyevrtyx/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/overlayed/9j0jnwVWRyevrtyx/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/overlayed/9j0jnwVWRyevrtyx/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/overlayed/9j0jnwVWRyevrtyx/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/overlayed/9j0jnwVWRyevrtyx/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/overlayed/9j0jnwVWRyevrtyx/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Overlay Ads - Overlayed\">\u003cmeta data-mint-head property=\"og:description\" content=\"Ads allow you to monetize your overlay, this guide will cover various utilities we provide for managing them.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Overlayed\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.overlayed.gg/ads/introduction\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://overlayed.mintlify.site/_mintlify/api/og/v2?division=Ads\u0026amp;title=Overlay+Ads\u0026amp;description=Ads+allow+you+to+monetize+your+overlay%2C+this+guide+will+cover+various+utilities+we+provide+for+managing+them.\u0026amp;theme=445349523a3ea9ff343c424e\u0026amp;signature=bd2babab038b9996c5234efbff1efee31855d550a6ed5141616298e4a98c3fd8\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Overlay Ads - Overlayed\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Ads allow you to monetize your overlay, this guide will cover various utilities we provide for managing them.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://overlayed.mintlify.site/_mintlify/api/og/v2?division=Ads\u0026amp;title=Overlay+Ads\u0026amp;description=Ads+allow+you+to+monetize+your+overlay%2C+this+guide+will+cover+various+utilities+we+provide+for+managing+them.\u0026amp;theme=445349523a3ea9ff343c424e\u0026amp;signature=bd2babab038b9996c5234efbff1efee31855d550a6ed5141616298e4a98c3fd8\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/overlayed/9j0jnwVWRyevrtyx/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Overlayed\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#3489eb\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.overlayed.gg/ads/introduction\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/ads/introduction.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.overlayed.gg/#organization\",\"name\":\"Overlayed\",\"url\":\"https://docs.overlayed.gg\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/overlayed/NjkLE7VgHNllkGf9/logo/logo-with-text-dark.webp?fit=max\u0026auto=format\u0026n=NjkLE7VgHNllkGf9\u0026q=85\u0026s=9a95df5e68f6e3a67cd604bc4ffc3436\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.overlayed.gg#website\",\"name\":\"Overlayed\",\"url\":\"https://docs.overlayed.gg\",\"publisher\":{\"@id\":\"https://docs.overlayed.gg/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.overlayed.gg/ads/introduction#webpage\",\"url\":\"https://docs.overlayed.gg/ads/introduction\",\"name\":\"Overlay Ads\",\"description\":\"Ads allow you to monetize your overlay, this guide will cover various utilities we provide for managing them.\",\"dateModified\":\"2026-10-16T04:51:49.618Z\",\"isPartOf\":{\"@id\":\"https://docs.overlayed.gg#website\"},\"breadcrumb\":{\"@id\":\"https://docs.overlayed.gg/ads/introduction#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.overlayed.gg/ads/introduction#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Overlayed\",\"item\":\"https://docs.overlayed.gg\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Overlay Ads\",\"item\":\"https://docs.overlayed.gg/ads/introduction\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.overlayed.gg/ads/introduction#article\",\"headline\":\"Overlay Ads\",\"name\":\"Overlay Ads\",\"description\":\"Ads allow you to monetize your overlay, this guide will cover various utilities we provide for managing them.\",\"url\":\"https://docs.overlayed.gg/ads/introduction\",\"mainEntityOfPage\":{\"@id\":\"https://docs.overlayed.gg/ads/introduction#webpage\"},\"dateModified\":\"2026-10-16T04:51:49.618Z\",\"publisher\":{\"@id\":\"https://docs.overlayed.gg/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.overlayed.gg#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Overlayed\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"Overlayed\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/ads/introduction.md","siteName":"Overlayed","nav":{"global":null,"tabs":[{"tab":"Docs","groups":[{"group":"Get Started","pages":[{"title":"Welcome to Overlayed","href":"/introduction"},{"title":"Quickstart","href":"/quick-start"},{"title":"TypeScript First","href":"/typescript"}]},{"group":"Essentials","pages":[{"title":"App Structure","sidebarTitle":"App Structure","href":"/essentials/app-structure"},{"title":"Overlayed Config","sidebarTitle":"Overlayed Config","href":"/essentials/overlayed-config"},{"title":"Local Development","href":"/essentials/local-development"},{"title":"Overlay Events","href":"/essentials/overlay-events"},{"title":"Game Events","sidebarTitle":"Game Events","href":"/essentials/game-events"},{"title":"App Issue Handling","href":"/essentials/issue-handling"},{"title":"Security","href":"/essentials/security"}]},{"group":"Windows","pages":[{"title":"Overlay Windows","sidebarTitle":"Creating Windows","href":"/windows/introduction"},{"title":"Navigation Guard","href":"/windows/navigation-guard"},{"title":"Render Windows","href":"/windows/render-windows"},{"title":"Global Window Events","sidebarTitle":"Window Events","href":"/windows/events"}]},{"group":"Keybinds","pages":[{"title":"Keybinds","sidebarTitle":"Setup Keybinds","href":"/keybinds/introduction"}]},{"group":"Notices","pages":[{"title":"Notices","sidebarTitle":"Notifying Users","href":"/notices/introduction"}]},{"group":"Feature Flags","pages":[{"title":"Feature Flags","sidebarTitle":"Gating Features","href":"/feature-flags/introduction"}]},{"group":"Event \u0026 Log Tracking","pages":[{"title":"Event \u0026 Log Tracking","sidebarTitle":"Track Custom Analytics","href":"/event-tracking/introduction"}]},{"group":"Logging","pages":[{"title":"Logging","sidebarTitle":"How Logging Works","href":"/logging/introduction"},{"title":"User Feedback","sidebarTitle":"User Feedback","href":"/logging/user-feedback"},{"title":"Crash Dumps","sidebarTitle":"Crash Dumps","href":"/logging/crash-dumps"},{"title":"Debug Mode","sidebarTitle":"Debug Mode","href":"/logging/debug-mode"}]},{"group":"Deployment","pages":[{"title":"Understanding Bundles","href":"/deployment/introduction"},{"title":"Updates","sidebarTitle":"Updates","href":"/deployment/updates"},{"title":"Private Channels","sidebarTitle":"Private Channels","href":"/deployment/private-channels"},{"title":"Update Rules","sidebarTitle":"Update Rules","description":"Steer specific users onto a channel, pin them to a release, or freeze their updates","href":"/deployment/update-rules"}]},{"group":"Ads","pages":[{"title":"Overlay Ads","sidebarTitle":"Monetize Your Overlay","href":"/ads/introduction"},{"title":"Overlay Ads Configuration","sidebarTitle":"Configuration","description":"Learn how to configure targeting and refresh ads at runtime.","href":"/ads/configuration"},{"title":"Overlay Ads Setup","sidebarTitle":"Ad Unit Setup","href":"/ads/ads-setup"}]},{"group":"Advanced","pages":[{"title":"Blocking Input","href":"/advanced/blocking-input"},{"title":"Delayed Initialization","href":"/advanced/delayed-init"}]},{"group":"Extras","pages":[{"title":"Model Context Protocol","sidebarTitle":"MCP","href":"/extras/mcp"}]}]},{"tab":"Guides","pages":[{"title":"Guides","href":"/guides"}]},{"tab":"Packages","pages":[{"title":"Packages","href":"/packages/app"}]},{"tab":"Supported Games","pages":[{"title":"Supported Games","href":"/games/introduction"}]}]},"basePath":"","title":"Overlay Ads - Overlayed","deploymentId":"dpl_2pTxFtyBudBMYZiCw1MyvoA1wxpd","buildId":"dpl_2pTxFtyBudBMYZiCw1MyvoA1wxpd","dynamics":[],"chunks":[]}