> ## Documentation Index
> Fetch the complete documentation index at: https://learn.social.plus/llms.txt
> Use this file to discover all available pages before exploring further.

# Ads

> Fetch configured network ads and track ad impressions or link clicks with the Social+ SDKs.

Network ads are fetched through the core ad repository. The returned ad objects include display fields, linked advertiser or image data where available, and analytics methods for impression and click tracking.

## Platform Surface

| Platform   | Fetch network ads                                   | Track seen                                | Track clicked                                    |
| ---------- | --------------------------------------------------- | ----------------------------------------- | ------------------------------------------------ |
| TypeScript | `AdRepository.getNetworkAds()`                      | `ad.analytics.markAsSeen()`               | `ad.analytics.markLinkAsClicked()`               |
| iOS        | `AmityAdRepository.getNetworkAds()`                 | `ad.analytics.markAsSeen()`               | `ad.analytics.markLinkAsClicked()`               |
| Android    | `AmityCoreClient.newAdRepository().getNetworkAds()` | `adRepository.analytics(ad).markAsSeen()` | `adRepository.analytics(ad).markLinkAsClicked()` |
| Flutter    | `AmityCoreClient.newAdRepository().getNetworkAds()` | `adRepository.analytics(ad).markAsSeen()` | `adRepository.analytics(ad).markLinkAsClicked()` |

## Parameters

| Parameter   | Required      | Description                                                                                               |
| ----------- | ------------- | --------------------------------------------------------------------------------------------------------- |
| `ad`        | Tracking only | Ad object returned from the network ads response.                                                         |
| `placement` | Tracking only | Where the ad was displayed. SDK enum values include feed, story, comment, chat, and chat list placements. |
| `settings`  | No            | Network ad settings returned with the ad list. Use them to decide how your app presents ads.              |

## Fetch And Track Ads

Call the tracking methods when the ad is actually shown or when the ad link is clicked in your UI.

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { AdRepository } from "@amityco/ts-sdk";

  const networkAds = await AdRepository.getNetworkAds();
  const ad = networkAds.ads[0];

  if (ad) {
    const placement = Amity.AdPlacement.FEED;
    ad.analytics.markAsSeen(placement);
    ad.analytics.markLinkAsClicked(placement);
  }
  ```

  ```swift iOS theme={null}
  let adRepository = AmityAdRepository()
  let networkAds = try await adRepository.getNetworkAds()

  if let ad = networkAds.ads.first {
      ad.analytics.markAsSeen(placement: .feed)
      ad.analytics.markLinkAsClicked(placement: .feed)
  }
  ```

  ```kotlin Android theme={null}
  import com.amity.socialcloud.sdk.model.core.ad.AmityAdPlacement

  val adRepository = AmityCoreClient.newAdRepository()

  adRepository.getNetworkAds()
      .subscribe(
          { networkAds ->
              val ad = networkAds.getAds().firstOrNull()
              if (ad != null) {
                  adRepository.analytics(ad).markAsSeen(AmityAdPlacement.FEED)
                  adRepository.analytics(ad).markLinkAsClicked(AmityAdPlacement.FEED)
              }
          },
          { error -> handleGeneralError(error) }
      )
  ```

  ```dart Flutter theme={null}
  final adRepository = AmityCoreClient.newAdRepository();
  final networkAds = await adRepository.getNetworkAds();
  final ads = networkAds.getAds() ?? [];

  if (ads.isNotEmpty) {
    final ad = ads.first;
    await adRepository.analytics(ad).markAsSeen(AmityAdPlacement.FEED);
    await adRepository.analytics(ad).markLinkAsClicked(AmityAdPlacement.FEED);
  }
  ```
</CodeGroup>

## Notes

* Fetching ads returns both `ads` and `settings`. Use settings as display configuration from the SDK response.
* Track `markAsSeen` only after the ad is rendered in the placement you pass.
* Track `markLinkAsClicked` from the UI action that opens or handles the ad call-to-action link.
* Use the placement enum from each SDK instead of hardcoded placement strings.

## Related Topics

<CardGroup cols={3}>
  <Card title="Feed Overview" icon="newspaper" href="/social-plus-sdk/social/discovery-engagement/feed/overview">
    Place feed ads alongside feed content
  </Card>

  <Card title="Stories" icon="images" href="/social-plus-sdk/social/content-management/stories/overview">
    Use story placement when ads are displayed in stories
  </Card>

  <Card title="Message Preview" icon="message-circle" href="/social-plus-sdk/chat/engagement-features/message-preview">
    Coordinate ad placement with chat surfaces
  </Card>
</CardGroup>
