> For the complete documentation index, see [llms.txt](https://developers-apps-in-toss.toss.im/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers-apps-in-toss.toss.im/documentation/api-and-sdk-en/sdk/domains-api/ads/googleadmob.loadappsintossadmob.md).

# GoogleAdMob.loadAppsInTossAdMob

### Feature description

Preloads Google AdMob ads so they’re ready to be shown immediately when needed. When an ad is loaded successfully `onEvent` as a callback `type: 'loaded'` the event is delivered.

Before calling `GoogleAdMob.loadAppsInTossAdMob.isSupported()`You can check support with

### Type

```ts
GoogleAdMob.loadAppsInTossAdMob(params: LoadAdMobParams): () => void;
```

**Params**

```ts
interface LoadAdMobParams {
  options: LoadAdMobOptions;
  onEvent: (event: LoadAdMobEvent) => void;
  onError: (error: unknown) => void;
}

type LoadAdMobOptions = {
  /** This is the ad group ID. Please enter the value issued from the App in Toss console. */
  adGroupId: string;
  /** This value distinguishes the source of the ad request. */
  referrer?: string | null;
};

type LoadAdMobEvent = {
  type: "loaded";
  data: LoadAdMobResult;
};

type LoadAdMobResult = {
  /** This is the ad group ID. */
  adGroupId: string;
  /** This is the ad ID. */
  adUnitId: string;
  /** This is the ad load response information. */
  responseInfo: {
    /** This is an array of ad network response information. */
    adNetworkInfoArray: AdNetworkResponseInfo[];
    /** This is the loaded ad network response information. */
    loadedAdNetworkInfo: AdNetworkResponseInfo | null;
    /** This is the ID that identifies the ad response. */
    responseId: string | null;
  };
};

type AdNetworkResponseInfo = {
  /** This is the ad source ID. */
  adSourceId: string;
  /** This is the ad source name. */
  adSourceName: string;
  /** This is the ad source instance ID. */
  adSourceInstanceId: string;
  /** This is the ad source instance name. */
  adSourceInstanceName: string;
  /** This is the ad network class name. */
  adNetworkClassName: string | null;
};
```

**Response**

Returns the unsubscribe function(`() => void`). If called, subsequent events and errors will not be passed to the callback.

### Error

If ad loading fails, `onError` an error is passed to the callback. If called outside the Toss app webview environment, an error occurs at the time of the call.

### Example code

```js
import { Ads } from "@apps-in-toss/web-framework";

function loadAd() {
  if (!GoogleAdMob.loadAppsInTossAdMob.isSupported()) {
    console.warn("AdMob ads cannot be used in the current environment.");
    return;
  }

  GoogleAdMob.loadAppsInTossAdMob({
    options: { adGroupId: "AD_GROUP_ID" },
    onEvent: (event) => {
      if (event.type === "loaded") {
        console.log("Ad loaded successfully:", event.data.responseInfo.responseId);
      }
    },
    onError: (error) => {
      console.error("Ad loading failed:", error);
    },
  });
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://developers-apps-in-toss.toss.im/documentation/api-and-sdk-en/sdk/domains-api/ads/googleadmob.loadappsintossadmob.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
